CodeMemberMethod Constructor
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 CodeMemberMethod class.
public:
CodeMemberMethod();
public CodeMemberMethod();
Public Sub New ()
Examples
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());
}
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
Remarks
This constructor creates an empty CodeMemberMethod object.
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET