I'm learning about interface properties and ran into something that I thought should work based on MSDN and book examples, but it doesn't. If I implement the interface property explicitly, it's not recognized when my class instance tries to access, but works fine if I do it implicitly(not sure if that's the correct terminology).
interface IMyInterface
{
string Name { get; set; }
}
class MyClass : IMyInterface
{
private string name;
string IMyInterface.Name //works if not explicit: i.e., public string Name
{
get { return this.name; }
set { this.name = value; }
}
}
class Program
{
static void Main(string[] args)
{
MyClass myClass = new MyClass();
myClass.Name = "blah"; // fails
}
}