CodeMemberProperty クラスとは? わかりやすく解説

CodeMemberProperty クラス

型のプロパティ宣言表します

名前空間: System.CodeDom
アセンブリ: System (system.dll 内)
構文構文

<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeMemberProperty
    Inherits CodeTypeMember
Dim instance As CodeMemberProperty
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeMemberProperty : CodeTypeMember
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class CodeMemberProperty : public
 CodeTypeMember
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeMemberProperty extends CodeTypeMember
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeMemberProperty extends
 CodeTypeMember
解説解説
使用例使用例

CodeMemberProperty使用してget アクセサset アクセサを持つ string プロパティ定義するコード例次に示します

' Declares a property of type String named StringProperty.
Dim property1 As New CodeMemberProperty()
property1.Name = "StringProperty"
property1.Type = New CodeTypeReference("System.String")
property1.Attributes = MemberAttributes.Public
property1.GetStatements.Add(New CodeMethodReturnStatement(New
 CodeFieldReferenceExpression(New CodeThisReferenceExpression(),
 "testStringField")))
property1.SetStatements.Add(New CodeAssignStatement(New
 CodeFieldReferenceExpression(New CodeThisReferenceExpression(),
 "testStringField"), New CodePropertySetValueReferenceExpression()))

' A Visual Basic code generator produces the following source code for
 the preceeding example code:

'     Public Overridable Property StringProperty() As String
'         Get
'             Return Me.testStringField
'         End Get
'         Set(ByVal Value As String)
'             Me.testStringField = value
'         End Set
'     End Property

// Declares a property of type String named StringProperty.
CodeMemberProperty property1 = new CodeMemberProperty();
property1.Name = "StringProperty";
property1.Type = new CodeTypeReference("System.String");
property1.Attributes = MemberAttributes.Public;
property1.GetStatements.Add( new CodeMethodReturnStatement( new
 CodeFieldReferenceExpression(new CodeThisReferenceExpression(),
 "testStringField") ) );
property1.SetStatements.Add( new CodeAssignStatement( new
 CodeFieldReferenceExpression(new CodeThisReferenceExpression(),
 "testStringField"), new CodePropertySetValueReferenceExpression()));

// A C# code generator produces the following source code for the preceeding
 example code:

//       public virtual string StringProperty 
//       {
//              get 
//            {
//                return this.testStringField;
//            }
//            set 
//            {
//                this.testStringField = value;
//            }
//       }            
// Declares a property of type String named StringProperty.
CodeMemberProperty^ property1 = gcnew CodeMemberProperty;
property1->Name = "StringProperty";
property1->Type = gcnew CodeTypeReference( "System.String" );
property1->Attributes = MemberAttributes::Public;
property1->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression(
 gcnew CodeThisReferenceExpression,"testStringField" ) ) );
property1->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression(
 gcnew CodeThisReferenceExpression,"testStringField" ),gcnew CodePropertySetValueReferenceExpression
 ) );

// A C# code generator produces the following source code for the preceeding
 example code:
//       public virtual string StringProperty
//       {
//              get
//            {
//                return this.testStringField;
//            }
//            set
//            {
//                this.testStringField = value;
//            }
//       }
// Declares a property of type String named StringProperty.
CodeMemberProperty property1 = new CodeMemberProperty();
property1.set_Name("StringProperty");
property1.set_Type(new CodeTypeReference("System.String"));
property1.set_Attributes(MemberAttributes.Public);
property1.get_GetStatements().Add(new CodeMethodReturnStatement(new
    CodeFieldReferenceExpression(new CodeThisReferenceExpression()
,
    "testStringField")));
property1.get_SetStatements().Add(new CodeAssignStatement(new
 
    CodeFieldReferenceExpression(new CodeThisReferenceExpression()
,
    "testStringField"), new CodePropertySetValueReferenceExpression()));
//  /** @property 
//   */
//  public   String get_StringProperty()
//  {
//      return this.get_testStringField();
//  } //get_StringProperty
//
//  /** @property 
//   */
//  public void set_StringProperty (String value )
//  {
//      this.set_testStringField(value);
//  } //set_StringProperty
継承階層継承階層
System.Object
   System.CodeDom.CodeObject
     System.CodeDom.CodeTypeMember
      System.CodeDom.CodeMemberProperty
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からCodeMemberProperty クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCodeMemberProperty クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCodeMemberProperty クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CodeMemberProperty クラス」の関連用語

CodeMemberProperty クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CodeMemberProperty クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS