Monday, June 24, 2019

Set Default Value in property in c# or Set Value in property in c#

1. Using Constructor

class Person 
{
    public Person()
    {
        Name = "Default Name";
    }
    public string Name { get; set; }
}
2. Normal

private string name = "Default Name";
public string Name 
{
    get 
    {
        return name;
    }
    set
    {
        name = value;
    }
}

No comments:

Post a Comment

Linq Expression syntax for where condtion in linq

(Expression<Func<T, bool>> filter)