CodeMemberMethod Constructor
Collapse the table of content
Expand the table of content

CodeMemberMethod Constructor ()

 

Initializes a new instance of the CodeMemberMethod class.

Namespace:   System.CodeDom
Assembly:  System (in System.dll)

public CodeMemberMethod()

This constructor creates an empty CodeMemberMethod object.

The following code example shows the use of the CodeMemberMethod constructor to create a CodeMemberMethod instance. This 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());
}

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft