Optional property in a C# class

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 −


Inherited = false,
AllowMultiple = false)]
internal sealed class OptionalAttribute : Attribute { }

public class Employee {
   public string EmpName { get; set; }

   public string AlternativeName { get; set; }