Home > Net >  C # programming
C # programming

Time:10-19

For the original code and run the screenshots below thank you

CodePudding user response:

Only implement multiple interfaces zhangs method that point the baidu



 
Public class Program
{
Private static void Main (string [] args)
{
Student Student=new Student ()
{
ID=0,
Name="Test"
};

((IPerson) student.) the Show ();
((IStudent) student.) the Show ();

Console.ReadKey();
}

}

Public interface IPerson
{
String Name {get; set; }
Void the Show ();
}

Public interface IStudent
{
Int ID {get; set; }
Void the Show ();
}

Public class Student: IPerson, IStudent
{
/* commonly known as complete attribute
Private int _id.
Public int ID
{
The get {return _id. }
The set {_id=value; }
}

Private string _name;
Public string Name
{
The get {return _name; }
The set {_name=value; }
}
*/

//automatic properties
Public int ID {get; set; }
Public string Name {get; set; }

Void IPerson. The Show ()
{
Console. WriteLine ($" Name is {Name} ");
}

Void IStudent. The Show ()
{
Console. WriteLine ($ID is {ID} ");
}
}

  •  Tags:  
  • C#
  • Related