Although there are already the similar questions, I haven't known if a use within them has more gains for performance so I have a question of it.
I heard read-only fields can be replaced at all constructors of their classes. But over the actual compilation environments including VS 2019, every properties have been able to be done regardless of whether they've had both methods or getters only. Their setters haven't been significant to get compiled successfully.
Here is the code below about this problem:
public class MyClass {
public readonly int value_field;
public int value_property { get; }
public MyClass(int x) {
this.value_field = x; // It's understandable
this.value_property = x; // This doesn't cause any errors.
}
}
Then, what is a better choice for performance and productivity?