Reputation: 270
Here's the scenario,
I have a silverlight C1 Datacolumn, and I want to check its type.
I know of two ways to do so:
SilverLightColumn.DataType.Equals(GetType(Decimal))
And
SilverLightColumn.DataType Is GetType(String)
The .DataType is a System.Type.
Is one way better than the other, or are they equivalent?
Or, am I totally wrong and there exists a better way to check for the type?
Upvotes: 0
Views: 95
Reputation: 127603
They are not equivalent. If you had the following
Class Foo
'...
End Class
Class Bar Inherits Foo
'...
End Class
And the type of DataType
is the type for Bar
then
SilverLightColumn.DataType Is GetType(Foo)
will return true, however
SilverLightColumn.DataType.Equals(GetType(Foo))
will return false. Is
will return true for that type or any type that inherits from it, Equals
must be the exact same type.
Upvotes: 2
Reputation: 15943
SilverLightColumn.DataType Is GetType(String)
Is
will allow any type that inherits fronm it
SilverLightColumn.DataType = GetType(String)
=
Allows only the exact match
You can also use the TypeOf
operator instead of the GetType
method
Upvotes: 0