Set default value to a property
Hello !
Just a few days back I found out that setting default values to a property is very simple, Just follow the steps mentioned below -
- Make sure that you are using System.ComponentModel – (using System.ComponentModel;)
- Set the [DefaultValueAttribute("")] before the property
e.g.
[DefaultValueAttribute("")]
public string Website
{
get { return m_website; }
set { m_website = value; }
}
DefaultValueAttribute accepts various parameters, Use the desired one.
Advertisement
Leave a Comment