25 lines
452 B
Plaintext
25 lines
452 B
Plaintext
Trivial properties, which include no logic but setting and getting a backing field should be converted to auto-implemented properties, yielding cleaner and more readable code.
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
public class Car
|
|
{
|
|
private string _make;
|
|
public string Make // Noncompliant
|
|
{
|
|
get { return _make; }
|
|
set { _make = value; }
|
|
}
|
|
}
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
public class Car
|
|
{
|
|
public string Make { get; set; }
|
|
}
|
|
----
|