Attribute コンストラクタ
アセンブリ: mscorlib (mscorlib.dll 内)



パラメータのカスタム Attribute クラスとそのコンストラクタの定義を次のコード例に示します。
' Define a custom parameter attribute that takes a single message argument. <AttributeUsage(AttributeTargets.Parameter)> _ Public Class ArgumentUsageAttribute Inherits Attribute ' This is the attribute constructor. Public Sub New(UsageMsg As String) Me.usageMsg = UsageMsg End Sub ' New ' usageMsg is storage for the attribute message. Protected usageMsg As String ' This is the Message property for the attribute. Public Property Message() As String Get Return usageMsg End Get Set usageMsg = value End Set End Property End Class ' ArgumentUsageAttribute
// Define a custom parameter attribute that takes a single message argument. [AttributeUsage( AttributeTargets.Parameter )] public class ArgumentUsageAttribute : Attribute { // This is the attribute constructor. public ArgumentUsageAttribute( string UsageMsg ) { this.usageMsg = UsageMsg; } // usageMsg is storage for the attribute message. protected string usageMsg; // This is the Message property for the attribute. public string Message { get { return usageMsg; } set { usageMsg = value; } } }
// Define a custom parameter attribute that takes a single message argument. [AttributeUsage(AttributeTargets::Parameter)] public ref class ArgumentUsageAttribute: public Attribute { protected: // usageMsg is storage for the attribute message. String^ usageMsg; public: // This is the attribute constructor. ArgumentUsageAttribute( String^ UsageMsg ) { this->usageMsg = UsageMsg; } property String^ Message { // This is the Message property for the attribute. String^ get() { return usageMsg; } void set( String^ value ) { this->usageMsg = value; } } };
// Define a custom parameter attribute that takes a single message argument. /** @attribute AttributeUsage(AttributeTargets.Parameter) */ public class ArgumentUsageAttribute extends Attribute { // This is the attribute constructor. public ArgumentUsageAttribute(String usgMsg) { this.usageMsg = usgMsg; } //ArgumentUsageAttribute // usageMsg is storage for the attribute message. protected String usageMsg; // This is the Message property for the attribute. /** @property */ public String get_Message() { return usageMsg; } //get_Message /** @property */ public void set_Message(String value) { usageMsg = value; } //set_Message } //ArgumentUsageAttribute

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Attribute コンストラクタのページへのリンク