A property is optional if it is possible and valid for it to have null. A property whose CLR type cannot have null cannot be configured optional.
An example optional attribute usage −
Example
[AttributeUsage(AttributeTargets.Property,
Inherited = false,
AllowMultiple = false)]
internal sealed class OptionalAttribute : Attribute { }
public class Employee {
public string EmpName { get; set; }
[Optional]
public string AlternativeName { get; set; }
}