C# #define

Subscribe to C# #define 2 posts, 2 voices

 
Avatar 1 post

How do i use #define MAX 20 in c# or how do i use .h file in c#

 
Avatar Phil135 1 post

C# is quite a bit different than C++. If you’re trying to create a macro so that the keyword MAX gets replaced with 20, I’d recommend you use a constant instead.

public const int MAX = 20;

The C# compiler will actually compile the value 20 into the IL (Intermediate Language) so that is effectively what you want.

There is no need for a .h file in C#. Hope this helps.