Compilation error "IUser.UserName" in the explicit declaration of the interface is not a member of the interface - why should I do this?

I use the Asp.Net Identity framework, and I have a User class that 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 just upgraded to Version 2 of the Asp.Net Identity Framework, and I started getting a compilation error “IUser.UserName” in the explicit interface declaration is not a member of the interface. ”Everything was fine.

What's happening?

+4
source share
1 answer

Two things contributed to this:

  • You are implementing the UserName property of the IUser interface explicitly
  • 2 Framework Asp.Net Identity Framework IUser. UserName IUser, IUser.

, # , , , .

, :

public class User : IUser
{
   string IUser<string>.UserName { get { return Email;} set { Email = value;}}
}

, :

public interface Base
{
    string MyProperty { get; set; }
}

public interface Inherited : Base
{

}

public class Implementor : Inherited
{
    string Inherited.MyProperty { get; set; }
}
+9

Source: https://habr.com/ru/post/1540359/


All Articles