R4R
Right Place For Right Person TM

What is the difference between const and static read-only?

previous previous previous
Question:
What is the difference between const and static read-only?

Question: What is the difference between const and static read-only?


Answer
The difference is that static read-only can be modified by the containing class, but const can never be modified and must be initialized to a compile time constant. To expand on the static read-only case a bit, the containing class can only modify it: -- in the variable declaration (through a variable initializer). -- in the static constructor (instance constructors if it's not static).

By:kamal
Date:

What is the difference between const and static read-only?

Post Your Answers


User Name:
Answers:

Related Links

  1. What does the parameter Initial Catalog define inside Connection String?
  2. What is the top .NET class that everything is derived from?
  3. Can you allow class to be inherited, but prevent the method from being over-ridden?
  4. Can you change the value of a variable while debugging a C# application?
  5. Are private class-level variables inherited?
  6. Can you inherit multiple interfaces?
  7. How can I create a process that is running a supplied native executable (e.g., cmd.exe)?
  8. Describe the accessibility modifier “protected internal”.
  9. What does the term immutable mean?
  10. Can you store multiple data types in System.Array?
  11. What’s the .NET collection class that allows an element to be accessed using a unique key?
  12. .What class is underneath the SortedList class?
  13. Explain the three services model commonly know as a three-tier application?
  14. Can you allow a class to be inherited, but prevent the method from being over-ridden?
  15. .What’s an abstract class?
  16. .When do you absolutely have to declare a class as abstract?
  17. What is an interface class?
  18. What happens if you inherit multiple interfaces and they have conflicting method names?
  19. What’s the difference between an interface and abstract class?
  20. What is the difference between a Struct and a Class?
  21. What’s the implicit name of the parameter that gets passed into the set method/property of a class?
  22. What does the keyword “virtual” declare for a method or property?
  23. Can you declare an override method to be static if the original method is not static?
  24. What are the different ways a method can be overloaded?
  25. What’s a delegate?
  26. What’s a multicast delegate?
  27. What’s the implicit name of the parameter that gets passed into the class’ set method?
  28. How do you inherit from a class in C#?
  29. When you inherit a protected class-level variable, who is it available to?
  30. Describe the accessibility modifier protected internal.?
  31. . What does the keyword virtual mean in the method definition?
  32. Can you declare the override method static while the original method is non-static?
  33. Can you override private virtual methods?
  34. What’s an interface class?
  35. Is it possible to create custom events for an object
  36. Is it possible for objects that don't have an interface to support events?
  37. Is there an easy way to get help about an object's member
  38. what's Param?
  39. What's OUT Keyword?
  40. What's REF Keyword?
  41. What's Delegate?
  42. Wat's feature of delegate?
  43. Wat's Property?
  44. What is Method Overloading ?
  45. What is Partial types?
  46. What is Aliases?
  47. What is Static classes?
  48. What is Methods?
  49. What is indexer?
  50. What is Event?

Question: What is the difference between const and static read-only?

Back Home Next

New Updates

Topics

Topics

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R