Auto-implemented properties C# 3.0 generate a hidden backing field.
C# 7.3 allows you to annotate the hidden backing field with attributes.
Code
C#
[Serializable]
class Location
{
[field:NonSerialized]
public string Name { get; set; }
public decimal Latitude { get; set; }
public decimal Longitude { get; set; }
}C#
[Serializable]
class Location
{
[NonSerialized]
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
public decimal Latitude { get; set; }
public decimal Longitude { get; set; }
}