Optional property in a C# class

CsharpProgrammingServer Side Programming

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; }
Published on 14-Aug-2018 16:16:08