I want to provide access to a getter or setter for a property at the interface level so that the same runs in the class that implements it. I want to do something like below:
public interface IExample
{
string Name
{
get;
internal set;
}
}
public class Example : IExample
{
private string _name = String.Empty;
string Name
{
get
{
return _name;
}
internal set
{
_name = value;
}
}
}
But unfortunately, from what I know, this is forbidden in C #. I think this is because the interface is only intended to expose what is publicly available (I have no idea!).
I need a way here to implement this using any other encoding pattern (preferably using an interface) that will help me provide specific access to the getter or setter properties in all of its implemented classes.
I googled it and tried to go through the MSDN docs for this, but no luck!