About 50 results
Open links in new tab
  1. 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?

  2. .net - C# naming convention for constants? - Stack Overflow

    Oct 28, 2008 · The recommended naming and capitalization convention is to use P ascal C asing for constants (Microsoft has a tool named StyleCop that documents all the preferred conventions and …

  3. c# - Enums and Constants. Which to use when? - Stack Overflow

    Aug 8, 2015 · I was doing some reading on enums and find them very similar to declaring constants. How would I know when to use a constant rather than an enum or vice versa. What are some of the …

  4. .net - C# Constants Management Best Practices - Stack Overflow

    Jul 31, 2022 · I'm a 22 yo dev and some days ago I looked out for the best practices to store and manage constants in a project. I found a guy on StackOverflow that said that you must create a static …

  5. string - Static Constants in C# - Stack Overflow

    I have this code; using System; namespace Rapido { class Constants { public static const string FrameworkName = "Rapido Framework"; } } Visual Studio tells me: The constant '

  6. What is the difference between const and readonly in C#?

    There is notable difference between const and readonly fields in C#.Net const is by default static and needs to be initialized with constant value, which can not be modified later on.

  7. What's the best way to implement a global constant in C#?

    Dec 9, 2011 · 1) public const string ConstName = "a value"; 2) public readonly string ConstName = "a value"; 3) To be stored in a public resource file. What would be the best approach to define public …

  8. How to declare a class instance as a constant in C#?

    50 Constants have to be compile time constant, and the compiler can't evaluate your constructor at compile time. Use readonly and a static.

  9. Defining constants by scope in C# - Stack Overflow

    I've always been in the habit of defining constants at the class level: public class MyClass { private const int SomeNumber = 10; ... } But, I recently worked with someone who believes tha...

  10. Class Library of Constants--Best Practice? - Stack Overflow

    Jun 5, 2013 · 8 Back in the days of coding windows applications in c, there were similar files #included in windows which consisted of long lists of #defines creating constants. Various c applications emulated …