Can you say how to set readonly property in property method(get and se开发者_开发技巧t).
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;}}
精彩评论