メソッド、フィールド、またはプロパティの COM ディスパッチ ID (DISPID) を指定します。
この型のすべてのメンバの一覧については、DispIdAttribute メンバ を参照してください。
System.Object
System.Attribute
System.Runtime.InteropServices.DispIdAttribute
<AttributeUsage(AttributeTargets.Method Or _
AttributeTargets.Property Or AttributeTargets.Field Or _
AttributeTargets.Event)>
NotInheritable Public Class DispIdAttribute Inherits Attribute
[C#]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property
| AttributeTargets.Field | AttributeTargets.Event)]
public sealed class DispIdAttribute : Attribute
[C++]
[AttributeUsage(AttributeTargets::Method |
AttributeTargets::Property | AttributeTargets::Field |
AttributeTargets::Event)]
public __gc __sealed class DispIdAttribute : public Attribute
[JScript]
public
AttributeUsage(AttributeTargets.Method | AttributeTargets.Property
| AttributeTargets.Field | AttributeTargets.Event)
class DispIdAttribute extends Attribute
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
この属性は、メソッド、フィールド、またはプロパティに適用できます。
この属性は、記述されるメソッド、フィールド、またはプロパティの DISPID を格納します。一意の DISPID は、通常、共通言語ランタイムによって割り当てられますが、この属性を使用して特定の DISPID をメソッドに割り当てることができます。タイプ ライブラリをインポートする場合、この属性は DISPID が割り当てられたすべてのメソッドに適用されます。これによって、同じメソッドのすべてのマネージ実装は、COM に公開された場合に、同じ DISPID を保持します。
使用例
[Visual Basic, C#, C++] DISPID をクラスのメンバに明示的に割り当てる方法を次の例に示します。
Imports System.Runtime.InteropServices
Class SampleClass
Public Sub New()
'Insert code here.
End Sub
<DispIdAttribute(8)> _
Public Sub MyMethod()
'Insert code here.
End Sub
Public Function MyOtherMethod() As Integer
'Insert code here.
Return 0
End Function
<DispId(9)> _
Public MyField As Boolean
End Class
[C#]
using System.Runtime.InteropServices;
public class MyClass
{
public MyClass() {}
[DispId(8)]
public void MyMethod() {}
public int MyOtherMethod() {
return 0;
}
[DispId(9)]
public bool MyField;
}
[C++]
using namespace System::Runtime::InteropServices;
public __gc class MyClass
{
public:
MyClass() {}
public:
[DispId(8)]
void MyMethod() {}
public:
int MyOtherMethod() {
return 0;
}
public:
[DispId(9)]
bool MyField;
};
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Runtime.InteropServices
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
アセンブリ: Mscorlib (Mscorlib.dll 内)