CodeSnippetTypeMember Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the CodeSnippetTypeMember class.
Overloads
CodeSnippetTypeMember() |
Initializes a new instance of the CodeSnippetTypeMember class. |
CodeSnippetTypeMember(String) |
Initializes a new instance of the CodeSnippetTypeMember class using the specified text. |
CodeSnippetTypeMember()
- Source:
- CodeSnippetTypeMember.cs
- Source:
- CodeSnippetTypeMember.cs
- Source:
- CodeSnippetTypeMember.cs
- Source:
- CodeSnippetTypeMember.cs
Initializes a new instance of the CodeSnippetTypeMember class.
public:
CodeSnippetTypeMember();
public CodeSnippetTypeMember ();
Public Sub New ()
Applies to
CodeSnippetTypeMember(String)
- Source:
- CodeSnippetTypeMember.cs
- Source:
- CodeSnippetTypeMember.cs
- Source:
- CodeSnippetTypeMember.cs
- Source:
- CodeSnippetTypeMember.cs
Initializes a new instance of the CodeSnippetTypeMember class using the specified text.
public:
CodeSnippetTypeMember(System::String ^ text);
public CodeSnippetTypeMember (string text);
new System.CodeDom.CodeSnippetTypeMember : string -> System.CodeDom.CodeSnippetTypeMember
Public Sub New (text As String)
Parameters
- text
- String
The literal code fragment for the type member.
Examples
The following example demonstrates the use of the CodeSnippetTypeMember constructor to create an instance of the CodeSnippetTypeMember class. This code example is part of a larger example provided for the GenerateCodeFromMember method.
static void GenCodeFromMember(CodeDomProvider provider, CodeGeneratorOptions options)
{
options.BracingStyle = "C";
CodeMemberMethod method1 = 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")));
StringWriter sw = new StringWriter();
provider.GenerateCodeFromMember(method1, sw, options);
snippetMethod = new CodeSnippetTypeMember(sw.ToString());
}
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
End Class