Thursday, April 21, 2011

Urgent Please in asp.net

Can u say how to set readonly property in property method(get and set)

if anybodies knows please share with me...............

From stackoverflow
  • You can either only give your property a getter:

    private string _name;
    
    public string Name { get { return _name; } }
    

    Or you can give the accessors different visibilities:

    public string Name { get; private set; }
    
  • You simply omit the setter:

     private string myField;
     public string MyReadOnlyProperty {get { return myField;}}
    

0 comments:

Post a Comment