We have a C++ code that defines a unified naming convention (majorly for multiplatform reasons).
For example:
#define FOO_UINT32 unsigned long
and
#define FOO_TRUE true
now, we want to port some of this code to C#.
For the first define in the example I figured out that I need:
using FOO_UINT32 = System.UInt32;
The question is? How do I do the second one?
Since
trueis not a type, you can’t utilize ausingdirective to alias it. You can create astaticclass with aconstmember to get a similar result:Then you can say
bool x = PortConstants.FOO_TRUE;. I’d recommend just usingtrue, though.You may also want to drop the
usingalias forUInt32as well, since the CLR type won’t be changing, and is consistent across platforms for which a CLR implementation is available.