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
true
is not a type, you can't utilize ausing
directive to alias it. You can create astatic
class with aconst
member 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
using
alias forUInt32
as well, since the CLR type won't be changing, and is consistent across platforms for which a CLR implementation is available.