I'm using the Asp.Net Identity framework, and I have a User class which looks like this:
public class User : IUser
{
public string Id {get; private set;}
public string Email {get; set;}
string IUser.UserName { get { return Email;} set { Email = value;}}
}
I've just upgraded to version 2 of Asp.Net Identity Framework, and I've started getting the compilation error "'IUser.UserName' in explicit interface declaration is not a member of interface". Everything was fine before.
What is happening?
Two things contributed to this:
When you implement interfaces explicitly, C# expects you to qualify the member name with the name of the least-derived interface, not the name of an interface which may inherit from it.
To fix your code, you need to do this:
public class User : IUser
{
string IUser<string>.UserName { get { return Email;} set { Email = value;}}
}
Bonus Example
Here's a complete example which generates the same error message:
public interface Base
{
string MyProperty { get; set; }
}
public interface Inherited : Base
{
}
public class Implementor : Inherited
{
string Inherited.MyProperty { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With