J
Jimi
I was wondering if there was a VB.NET equivalent to the following C#
statement:
SomeType SomeVar = SomeOtherVar as SomeType;
I know that in VB.NET you could have:
Dim SomeVar As SomeType = CType(SomeOtherVar, SomeType)
but this throws an exception if the cast fails while the C# example
above just sets SomeVar to null if the cast fails. (the C#
equivalent to this is "SomeType SomeVar = (SomeType)SomeOtherVar;".
statement:
SomeType SomeVar = SomeOtherVar as SomeType;
I know that in VB.NET you could have:
Dim SomeVar As SomeType = CType(SomeOtherVar, SomeType)
but this throws an exception if the cast fails while the C# example
above just sets SomeVar to null if the cast fails. (the C#
equivalent to this is "SomeType SomeVar = (SomeType)SomeOtherVar;".