neuromancer neuromancer - 1 year ago 75
C# Question

How to define constants in Visual C# like #define in C?

In C you can define constants like this

#define NUMBER 9

so that wherever NUMBER appears in the program it is replaced with 9. But Visual C# doesn't do this. How is it done?

Answer Source
public const int NUMBER = 9;

You'd need to put it in a class somewhere, and the usage would be ClassName.NUMBER