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

C++ Equivalent to C# 'object'

In C++17, the std::any type offers a good equivalent to System.Object.

C# C++ (C++17)
object o = 1;
int i = (int)o;
Type t = o.GetType();
#include <any>
#include <typeinfo>

std::any o = 1;
int i = std::any_cast<int>(o);
std::type_info t = o.type();

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

Additional resource: C++ and C# Equivalents

Copyright © 2004 – 2021 Tangible Software Solutions, Inc.