Reputation: 5817
I have an Interface that has only one property like below
public interface IExtendable
{
Hashtable ExtendedProperties { get; set;}
}
I want setter to be private but it doesnt allow because its coming from an Interface and everyhing should be public in it as I know.
So what can be the best practice to allowing private setter ?
Thanks in advance,
Upvotes: 1
Views: 1893
Reputation: 9394
You can not add a private setter to an interface. If you want to have a private setter, then your interface will need to look like this:
public interface IExtendable
{
Hashtable ExtendedProperties { get; }
}
And in the implementation of the interface you can add your private setter.
Upvotes: 10
Reputation: 10347
private interface IExtendable
{
Hashtable ExtendedProperties { get; }
}
private class Extendable: IExtendable
{
Hashtable ExtendedProperties { get; private set; }
}
Upvotes: 3