本文整理匯總了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'