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

C++ Equivalent to C# Casts

The closest equivalent to the standard C# casting operator is the static_cast operator in C++.   The behavior of this C++ operator is subtly different from the C# casting operator though, so you should always test the behavior of your new C++ code.

The C# as operator is converted to the C++ dynamic_cast operator.

C# C++
x = (FooType)myObject;
x = myObject as FooType;
x = static_cast<FooType*>(myObject);
x = dynamic_cast<FooType*>(myObject);


Use C# to C++ Converter to convert from C# to C++.     

Additional resource: C++ and C# Equivalents


Copyright © 2004 – 2019 Tangible Software Solutions, Inc.