• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

C# Equivalent to VB Casts

The closest equivalent to the standard VB casting operators (CType and the corresponding CInt, CStr, etc.) are calls to the System.Convert methods if the appropriate method exists, otherwise they are converted to the standard C# casting operator. 

The behavior of both the System.Convert methods and the standard C# casting operator are subtly different from the VB casting operators though, so you should always test the behavior of your converted C# code.

The C# equivalent to VB's DirectCast is the standard C# casting operator.

The VB TryCast operator always converts to the C# as operator.

Use Instant C# to convert from VB.NET to C#.     

Additional resource: VB.NET and C# Equivalents

Copyright © 2004 – 2021 Tangible Software Solutions, Inc.