次の方法で共有


CustomConstantAttribute クラス

コンパイラがフィールドまたはメソッド パラメータに対して永続化できる定数値を定義します。

この型のすべてのメンバの一覧については、CustomConstantAttribute メンバ を参照してください。

System.Object
   System.Attribute
      System.Runtime.CompilerServices.CustomConstantAttribute
         System.Runtime.CompilerServices.DateTimeConstantAttribute
         System.Runtime.CompilerServices.IDispatchConstantAttribute
         System.Runtime.CompilerServices.IUnknownConstantAttribute

<AttributeUsage(AttributeTargets.Field Or _
   AttributeTargets.Parameter)>
<Serializable>
MustInherit Public Class CustomConstantAttribute   Inherits Attribute
[C#]
[AttributeUsage(AttributeTargets.Field |
   AttributeTargets.Parameter)]
[Serializable]
public abstract class CustomConstantAttribute : Attribute
[C++]
[AttributeUsage(AttributeTargets::Field |
   AttributeTargets::Parameter)]
[Serializable]
public __gc __abstract class CustomConstantAttribute : public   Attribute
[JScript]
public
   AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter)
 Serializable
abstract class CustomConstantAttribute extends Attribute

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

この属性は、フィールドまたはパラメータに適用できます。

このクラスはインスタンス化できません。

コンパイラは、このクラスから派生し、定数値の型を定義する固有のクラスを作成します。たとえば、コンパイラがフィールドまたはメソッド パラメータに対して 8 バイトの DateTime 定数を永続化できるようにする DateTimeConstantAttribute を参照してください。 System.Reflection を使用している場合は、このように CustomConstantAttribute から固有なクラスを派生させることによって、カスタムの定数属性をすべて簡単に検索できるようになります。

System.Runtime.CompilerServices のクラスはコンパイラ ライタ専用です。

必要条件

名前空間: System.Runtime.CompilerServices

プラットフォーム: 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 内)

参照

CustomConstantAttribute メンバ | System.Runtime.CompilerServices 名前空間