.Maui Blog

VB.net – check if an object is a certain type

Simply use the TypeOf operator to retrieve the type of an instance of an object.

For example to find out if an object is a string:

If TypeOf foo Is String Then
    Console.WriteLine("fooo is a string")
Else
    Console.WriteLine("foo is not a string")
End If
Exit mobile version