how to set default value of a property in class-c# code example Example: c# auto property set default value public int X { get; set; } = x; // C# 6 or higher