本文整理汇总了VB.NET中System.CodeDom.CodeMethodReferenceExpression.CodeMethodReferenceExpression构造函数的典型用法代码示例。如果您正苦于以下问题:VB.NET CodeMethodReferenceExpression构造函数的具体用法?VB.NET CodeMethodReferenceExpression怎么用?VB.NET CodeMethodReferenceExpression使用的例子?那么恭喜您, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.CodeDom.CodeMethodReferenceExpression
的用法示例。
在下文中一共展示了CodeMethodReferenceExpression构造函数的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: CodeGenExample
' 导入命名空间
Imports System.CodeDom
Imports System.CodeDom.Compiler
Public Class CodeGenExample
Shared Sub Main
' Declare a new type called Class1.
Dim class1 as New CodeTypeDeclaration("Class1")
' Declares a type constructor that calls a method.
Dim constructor1 As New CodeConstructor()
constructor1.Attributes = MemberAttributes.Public
class1.Members.Add( constructor1 )
' Creates a method reference for dict.Init.
Dim methodRef1 as New CodeMethodReferenceExpression(
New CodeVariableReferenceExpression("dict"),
"Init",
New CodeTypeReference() {
New CodeTypeReference("System.Decimal"),
New CodeTypeReference("System.Int32")})
' Invokes the dict.Init method from the constructor.
Dim invoke1 As New CodeMethodInvokeExpression( methodRef1, new CodeParameterDeclarationExpression() {} )
constructor1.Statements.Add( invoke1 )
' Create a Visual Basic code provider
Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")
' Generate code and send the output to the console
provider.GenerateCodeFromType(class1, Console.Out, New CodeGeneratorOptions())
End Sub
End Class
' The Visual Basic code generator produces the following source code for the preceeding example code:
'
' Public Class Class1
'
' Public Sub New()
' MyBase.New
' dict.Init(Of Decimal, Integer)
' End Sub
' End Class'