What is difference between const and static in c#?



What is difference between const and static in c#?..

Answer / Ajay Pal Singh

"'const' is used to declare constant values that must be initialized at compile-time, while 'static' can be used for variables or methods that belong to the type itself rather than an individual instance. Constants have a fixed value throughout the lifetime of the program, whereas static variables retain their values between method calls but can be modified within those calls."n

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class?

1 Answers  


How many types of constructors are there in c#?

1 Answers  


What are the boolean data types in c#?

1 Answers  


Differentiate between response.expires and response.expiresabsolute?

1 Answers  


What is constants in c#?

1 Answers  


if a method is marked as protected internal who can access it?

1 Answers   Siebel Systems,


I have a very important query in my mind. Please help me regarding this. I don't have any real time exp in .net. But I have a knowledge it .net. I got an offer from an MNC company as a software developer has I had kept 2 years of fake exp. Even though for this job I had worked hard to crack interview for about an year. So, I would like to know how difficult it will be for working in real time as I don't have real time exp. Please tell me as soon as possible bcoz I need to join by next month. Can i sustain over there for a longer time or not. And also let me know how to work pressure will be over there. Please help me regarding this. I'm getting tension thinking about it. Thank you.

1 Answers  


What is private constructor c#?

1 Answers  


What is a race condition?

1 Answers  


What is the use of New Keyword

15 Answers  


how to use msflexgrid in asp.net

1 Answers   nSoft, Unichem,


Explain the three services model (three-tier application).

3 Answers   4Cplus,


Categories