KeywordAttribute クラス

説明

メソッドがキーワードであることを指定します。キーワードの名前が指定されていない場合、アノテーション メソッドの名前がキーワード名として使用されます。

構文

C#
[AttributeUsageAttribute(AttributeTargets.Method)]
public class KeywordAttribute : Attribute
VB
'Declaration
<AttributeUsageAttribute(AttributeTargets.Method>
Public Class KeywordAttribute Inherits Attribute

プロパティ

名前 説明
Name プロパティ (KeywordAttribute) キーワードの名前を取得します。デフォルト値は空の文字列です。
Description プロパティ (KeywordAttribute) キーワードの説明を取得します。デフォルト値は空の文字列です。

例:2 つの引数を持つキーワードの作成

引数 username および password を持つ Login キーワードを作成するには、次のサンプル コードを使用します。

C#
[Keyword]
public void Login(string username, string password) {
  // keyword implementation
}
VB
<Keyword()>
Public Sub Login(username As String, password As String)
  ' keyword implementation
End Sub

例:キーワードの名前の指定

新しいキーワードを作成するときにキーワードの名前を指定するには、次のサンプル コードを使用します。

C#
[Keyword("Login user")]
public void Login(string username, string password) {
  // keyword implementation
}
VB
<Keyword("Login user")>
Public Sub Login(username As String, password As String)
  ' keyword implementation
End Sub