In C++ I’d often create a code file containing constants, enums, #define-s, macros etc.
What’s the best practice for that in C#? Do I create a static class and fill it with that data? or is there some other way ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t need a static class for enums – they can be top-level (meaning: namespace level). Yes, you need a class for constants (and a static class would suffice), but I would tend to have multiple classes – one per intent. There is no need to cram them all together.
In C#, any
#defineonly apply to that file, so there is not much point having a class for them (put them in the project / build-script instead). And macros don’t exist.