Can a class implement two interfaces at the same time?

I tried to do something like this:

class Student: IPersonalDetails: IOtherDetails
{
      //Code
}

He gives an error. Why can't I implement two interfaces?

+5
source share
6 answers

Use a comma between interface types, e.g.

class Student: IPersonalDetails, IOtherDetails
{
      //Code
}
+19
source

Change it to

class Student: IPersonalDetails, IOtherDetails
{
  //Code
}
+9
source

, , .

+5

! . 2. , , .

+1

, . , .

, . , . , .

0

Yes, or something like that, which, of course, aims at a completely different design goal, and you could say that this is actually another interface due to the polymorphic nature of inheritance, but still:

public interface IEntity 
{
    void DoTask();
}

public interface IExtendedTaskEntity : IEntity
{
    void DoExtendedTask();
}

public class ConcreteEntity : IExtendedTaskEntity 
{

    #region IExtendedTaskEntity Members

    public void DoExtendedTask()
    {
        throw new NotImplementedException();
    }

    #endregion

    #region IEntity Members

    public void DoTask()
    {
        throw new NotImplementedException();
    }

    #endregion
}
-1
source

All Articles