include::../description.adoc[]

== Noncompliant Code Example

----
public class Person
{
    private int _birthYear;  // Noncompliant

    Person(int birthYear) 
    {
        _birthYear = birthYear;
    }
}
----

== Compliant Solution

----
public class Person
{
    private readonly int _birthYear;

    Person(int birthYear) 
    {
        _birthYear = birthYear;
    }
}
----

== Exceptions

* Fields with attributes are ignored.
* Fields of type ``++struct++`` that are not primitive or pointer types are also ignored because of possible unwanted behavior.

== See

* https://ericlippert.com/2008/05/14/mutating-readonly-structs/[Mutating readonly structs]

ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]
