#define in C#
-
hi, i want to know any method to implement #define similar thing in C#. i need to declare some const like below in C++ #define STATUS_A 'a' currently, i used public const char STATUS_A = 'a'; or enum STATUS { A = 'a'; } apart from above methods, any other method? thanks, jim
-
hi, i want to know any method to implement #define similar thing in C#. i need to declare some const like below in C++ #define STATUS_A 'a' currently, i used public const char STATUS_A = 'a'; or enum STATUS { A = 'a'; } apart from above methods, any other method? thanks, jim
You already found it. C# doesn't support compiler directives. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
You already found it. C# doesn't support compiler directives. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
Not quite. You can use defines in C# as well, although not exactly like in C/C++. You _can_ define symbols at the very beginning of a C# file (before any using directives) or in the project settings in VS.NET. In your code you can use #if, #elif, #else and #endif and some other preprocessor directives to compile or not compile part of your code, depending on the symbols you define. MSDN has a list: C# preprocessor directives[^] Regards, mav
-
Not quite. You can use defines in C# as well, although not exactly like in C/C++. You _can_ define symbols at the very beginning of a C# file (before any using directives) or in the project settings in VS.NET. In your code you can use #if, #elif, #else and #endif and some other preprocessor directives to compile or not compile part of your code, depending on the symbols you define. MSDN has a list: C# preprocessor directives[^] Regards, mav
My bad! :-> I could have sworn that it didn't. This topic came up before about 6 months ago and I thought that was what the answer was. :-D RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome