Mega Code Archive

 
Categories / VB.Net Tutorial / Reflection
 

Use Equals to compare two types

Imports System Imports System.Reflection Class Example     Public Shared Sub Main()          Dim a As Type = GetType(System.String)         Dim b As Type = GetType(System.Int32)         Console.WriteLine("{0} = {1}: {2}", a, b, a.Equals(b))         a = GetType(Example)         b = New Example().GetType()         Console.WriteLine("{0} is equal to {1}: {2}", a, b, a.Equals(b))         b = GetType(Type)         Console.WriteLine("typeof({0}).Equals(typeof({1})): {2}", a, b, a.Equals(b))     End Sub  End Class