C++ vs C#

Table of Contents

Type Equivalents

Type Equivalents

C# C++
boolbool
byteunsigned char
sbytesigned char
charwchar_t (assuming 16-bit)
byte, ushort, uint, ulong uint8_t, uint16_t, uint32_t, uint64_t
sbyte, short, int, long int8_t, int16_t, int32_t, int64_t
float, double float, double, on most implementations
System.UIntPtr, System.IntPtr uintptr_t, intptr_t,
voidvoid
varauto
objectstd::shared_ptr<std::any>, but GCed
 
System.WeakReference<T>std::weak_ptr<T>
ReferenceTypestd::shared_ptr<ReferenceType>, but GCed
ValueTypeValueType
ValueType?std::option<ValueType>
 
System.Stringstd::shared_ptr<const std::wstring>
System.Text.StringBuilderstd::shared_ptr<std::wstring>
 
S...Collections.Generic.List<V>std::vector<V>
S...Collections.Generic.Dictionary<K,V>std::unordered_map<K,V>
S...Collections.Generic.HashSet<V>std::unordered_set<V>
S...Collections.Generic.LinkedList<V>std::list<V>
S...Collections.Generic.Queue<V>std::queue<V>
S...Collections.Generic.Queue<V>std::queue<V>
S...Collections.Generic.SortedDictionary<K,V>std::map<K,V>
S...Collections.Generic.SortedSet<V>std::set<V>
S...Collections.Generic.Stack<V>std::stack<V>
S...Collections.Generic.KeyValuePair<K,V>std::pair<K,V>
System.Tuple<A,B,C>std::tuple<A,B,C>
 
System.Func<A,B,R>std::function<R (A,B)>
System.Action<A,B>std::function<void (A,B)>

— MaulingMonkey