c# property declaration code example
Example 1: c# accessors
private string _name = "Hello";
public string Name
{
get
{
return _name;
}
protected set
{
_name = value;
}
}
Example 2: c# properties making string required
using System.ComponentModel.DataAnnotations;
{
[Required(ErrorMessage = "DocumentType is required.")]
public string DocumentType
{
get { return _documentType; }
set { _documentType = value; }
}
}