Represents a member of a type using a literal code fragment.
Assembly: System (in System.dll)
Thetype exposes the following members.
|Attributes||Gets or sets the attributes of the member. (Inherited from CodeTypeMember.)|
|Comments||Gets the collection of comments for the type member. (Inherited from CodeTypeMember.)|
|CustomAttributes||Gets or sets the custom attributes of the member. (Inherited from CodeTypeMember.)|
|EndDirectives||Gets the end directives for the member. (Inherited from CodeTypeMember.)|
|LinePragma||Gets or sets the line on which the type member statement occurs. (Inherited from CodeTypeMember.)|
|Name||Gets or sets the name of the member. (Inherited from CodeTypeMember.)|
|StartDirectives||Gets the start directives for the member. (Inherited from CodeTypeMember.)|
|Text||Gets or sets the literal code fragment for the type member.|
|UserData||Gets the user-definable data for the current object. (Inherited from CodeObject.)|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
can represent a member of a type using a literal code fragment that is included directly in the source without modification. This code can be included in the type declaration.
A stores a section of code, exactly in its original format, as a string. The CodeDOM does not translate literal code fragments. Literal code fragments are stored and output in their original format. CodeDOM objects that contain literal code are provided so developers can encapsulate code that is already in the target language.
The Text property contains the literal code for the type member.
The following example demonstrates the use of the class to store literal code in a string format. This code example is part of a larger example provided for the GenerateCodeFromMember method.
Shared Sub GenCodeFromMember(ByVal provider As CodeDomProvider, ByVal options As CodeGeneratorOptions) options.BracingStyle = "C" Dim method1 As New CodeMemberMethod() method1.Name = "ReturnString" method1.Attributes = MemberAttributes.Public method1.ReturnType = New CodeTypeReference("System.String") method1.Parameters.Add(New CodeParameterDeclarationExpression("System.String", "text")) method1.Statements.Add(New CodeMethodReturnStatement(New CodeArgumentReferenceExpression("text"))) Dim sw As New StringWriter() provider.GenerateCodeFromMember(method1, sw, options) snippetMethod = New CodeSnippetTypeMember(sw.ToString()) End Sub 'GenCodeFromMember End Class 'Program
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)