As I read here http://msdn.microsoft.com/en-us/library/75e8y5dd%28v=VS.100%29.aspx
It is possible to have get
in an Interface BUT NOT set
?
OR if I want getter and setter in Interface, do I have to use the old syntax getVar
setVar
just because new syntax doesn't fit Interface syntax?
Update: If I must omit set
in Interface, does this means I cannot enforce class to have setter which defeats the purpose of having an Interface in this case as I can only partially enforce?
No. I think you misunderstood. That article is about the possibility of having an interface with a readonly property (a property with only getter). But, if you need, you can put also the setter in the interface:
interface IHasProperty
{
string Property{ get;set; }
}
class HasProperty:IHasProperty
{
public string Property{ get;set; }
}