C Cralis Jul 13, 2010 #2 In VB it's : directcast & tryCast. What is the equivalent in C# ? Thanks Click to expand... TryParse and Parse, I think.
In VB it's : directcast & tryCast. What is the equivalent in C# ? Thanks Click to expand... TryParse and Parse, I think.
J Jeff Johnson Jul 13, 2010 #3 In VB it's : directcast & tryCast. What is the equivalent in C# ? Click to expand... DirectCast = (<data type>) in C# Example: int x = (int)someFloatVariable; I've never heard of TryCast, but I'm pretty sure the equivalent is the "as" keyword. SomeObject x = someOtherObject as SomeObject; If someOtherObject cannot be cast to SomeObject then x will be null.
In VB it's : directcast & tryCast. What is the equivalent in C# ? Click to expand... DirectCast = (<data type>) in C# Example: int x = (int)someFloatVariable; I've never heard of TryCast, but I'm pretty sure the equivalent is the "as" keyword. SomeObject x = someOtherObject as SomeObject; If someOtherObject cannot be cast to SomeObject then x will be null.
A Arne Vajhøj Jul 14, 2010 #4 DirectCast = (<data type>) in C# Example: int x = (int)someFloatVariable; I've never heard of TryCast, but I'm pretty sure the equivalent is the "as" keyword. SomeObject x = someOtherObject as SomeObject; If someOtherObject cannot be cast to SomeObject then x will be null. Click to expand... TryCast does the same. It was added in VB.NET 2005. Arne
DirectCast = (<data type>) in C# Example: int x = (int)someFloatVariable; I've never heard of TryCast, but I'm pretty sure the equivalent is the "as" keyword. SomeObject x = someOtherObject as SomeObject; If someOtherObject cannot be cast to SomeObject then x will be null. Click to expand... TryCast does the same. It was added in VB.NET 2005. Arne