Does it make sense to make an Interface readonly
?
While using Resharper 8.0, i got the following suggestion and I was not sure how this will help me.
What I've found from researching (still not clear how it works against an Interface):
- It's simply a check to ensure that once the object is fully constructed, that field cannot be pointed to a new value.
- The real advantage of this keyword is to generate immutable data structures. Immutable data structures by definition cannot be changed once constructed
- The readonly keyword is used to declare a member variable a constant, but allows the value to be calculated at runtime.
- Use readonly if you don't want to have to recompile external DLLs that reference the constant (since it gets replaced at compile time)
Cited: What are the benefits to marking a field as `readonly` in C#?