Why does resharper suggests using readonly in fields that are not changed?
c#, resharper
Solution
When it detects that you are not assigning to a variable except at initilization, it presumes that you don't want the variable to change. Making the variable readonly (or const) will prevent you from assigning to the variable in the future. Since this seems (by usage) to be the behavior you want, it makes the suggestion that you formalize it and derive the benefit of the protection.
Problem
to clarify the question, I'd like to add that I'm not asking why I should choose readonly over const or what are the benefits of readonly over const. I'm asking why to make a field readonly just because it's not changed (at the moment). for example: if I'd write the following class: ``` public class MyClass { public int _i = 5; // Code that doesn't change the value of i: ... } ``` Resharper will indicate that it can be made readonly. Thanks