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

Viewed 119415

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?

7 Answers

What is the "Visual C#"? There is no such thing. Just C#, or .NET C# :)

Also, Python's convention for constants CONSTANT_NAME is not very common in C#. We are usually using CamelCase according to MSDN standards, e.g. public const string ExtractedMagicString = "vs2019";

Source: Defining constants in C#

Related