CodeMemberProperty Class
Represents a declaration for a property of a type.
Assembly: System (in System.dll)
CodeMemberProperty can be used to represent the declaration for a property of a type.
The Type property specifies the data type of the property. The GetStatements property contains any get statement methods for the property. The SetStatements property contains any set statement methods for the property. The Parameters property specifies any parameters for the property, such as are required for an indexer property.
The following example code demonstrates use of a CodeMemberProperty to define a string property with get and set accessors.
' 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
System.CodeDom.CodeObject
System.CodeDom.CodeTypeMember
System.CodeDom.CodeMemberProperty
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.