G Guest Dec 10, 2004 #1 under the covers is type casting in VB.Net the same as C# ? myObject = CType(..,..) in VB.Net vs myObject = (SomeClass)aObject
under the covers is type casting in VB.Net the same as C# ? myObject = CType(..,..) in VB.Net vs myObject = (SomeClass)aObject
M Mattias Sjögren Dec 10, 2004 #2 under the covers is type casting in VB.Net the same as C# ? myObject = CType(..,..) in VB.Net vs myObject = (SomeClass)aObject Click to expand... Not quite. CType performs conversion in addition to casting, so for example the following works Dim o As Object = "5" Dim i As Integer = CType(o, Integer) ' or CInt(o) but the following doesn't object o = "5"; int i = (int)o; In that sense, VB.NET's DirectCast operator is more of a strict casting operator. Mattias
under the covers is type casting in VB.Net the same as C# ? myObject = CType(..,..) in VB.Net vs myObject = (SomeClass)aObject Click to expand... Not quite. CType performs conversion in addition to casting, so for example the following works Dim o As Object = "5" Dim i As Integer = CType(o, Integer) ' or CInt(o) but the following doesn't object o = "5"; int i = (int)o; In that sense, VB.NET's DirectCast operator is more of a strict casting operator. Mattias