I have this class:
public static class LinkExtensions
{
Within this class I have a lot of methods that use a constant. Can someone explain to me is it possible for me to declare a constant at the class level that I can use in all these methods?
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.
If you want it to be avaible only inside the class, make it private:
If you want it to be available outside the class, make it public:
(Note that a constant that is used from a different project will use the value of the constant, not read it from your project. If you change the constant but doesn’t recompile the other project that uses it, it will still use the old value. You might consider making it a read-only property instead in that case.)