DispIdAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)
構文
<AttributeUsageAttribute(AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Event, Inherited:=False)> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class DispIdAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event, Inherited=false)] [ComVisibleAttribute(true)] public sealed class DispIdAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Event, Inherited=false)] [ComVisibleAttribute(true)] public ref class DispIdAttribute sealed : public Attribute
この属性は、メソッド、フィールド、またはプロパティに適用できます。
この属性は、記述されるメソッド、フィールド、またはプロパティの DISPID を格納します。一意の DISPID は、通常、共通言語ランタイムによって割り当てられますが、この属性を使用して特定の DISPID をメソッドに割り当てることができます。タイプ ライブラリをインポートする場合、この属性は DISPID が割り当てられたすべてのメソッドに適用されます。これによって、同じメソッドのすべてのマネージ実装は、COM に公開された場合に、同じ DISPID を保持します。
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
using System.Runtime.InteropServices; public class MyClass { public MyClass() {} [DispId(8)] public void MyMethod() {} public int MyOtherMethod() { return 0; } [DispId(9)] public bool MyField; }
System.Attribute
System.Runtime.InteropServices.DispIdAttribute
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- DispIdAttribute クラスのページへのリンク