本文整理匯總了VB.NET中System.Reflection.MethodBase.IsVirtual屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET MethodBase.IsVirtual屬性的具體用法?VB.NET MethodBase.IsVirtual怎麽用?VB.NET MethodBase.IsVirtual使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。
在下文中一共展示了MethodBase.IsVirtual屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: MyClass1
' 導入命名空間
Imports System.Reflection
Public Class MyClass1
Public Sub MyMethod()
End Sub
Public Shared Sub Main()
Dim m As MethodBase = GetType(MyClass1).GetMethod("MyMethod")
Console.WriteLine("The IsFinal property value of MyMethod is {0}.", m.IsFinal)
Console.WriteLine("The IsVirtual property value of MyMethod is {0}.", m.IsVirtual)
End Sub
End Class
示例2: Main
' 導入命名空間
Imports System.Reflection
Public Class ReflectionUtilities
Public Shared Function IsOverride(method As MethodInfo) As Boolean
Return Not method.Equals(method.GetBaseDefinition())
End Function
End Class
Module Example
Public Sub Main()
Dim equals As MethodInfo = GetType(Int32).GetMethod("Equals",
{ GetType(Object) } )
Console.WriteLine("{0}.{1} is inherited: {2}",
equals.ReflectedType.Name, equals.Name,
ReflectionUtilities.IsOverride(equals))
equals = GetType(Object).GetMethod("Equals", { GetType(Object) } )
Console.WriteLine("{0}.{1} is inherited: {2}",
equals.ReflectedType.Name, equals.Name,
ReflectionUtilities.IsOverride(equals))
End Sub
End Module
輸出:
Int32.Equals is inherited: True Object.Equals is inherited: False