Code inspection: Convert constructor into primary constructor
This inspection suggests using the C# 12 syntax of primary constructors for types that have a single public constructor. Primary constructor syntax improves readability and makes your code more concise.
public class Person
{
private readonly string myName;
private readonly int myAge;
public Person(string name, int age)
{
myName = name;
myAge = age;
}
}
public class Person(string name, int age)
{
private readonly string myName = name;
private readonly int myAge = age;
}
Last modified: 14 May 2024