Home > Net >  C # interface problem, few points, new bosses
C # interface problem, few points, new bosses

Time:09-22

The namespace interface
{
Class Program
{
Public interface fly
{
Dream Dream ();
}
Public class Dream
{

}
Public class People: fly
{
Public Dream Dream ()
{
Dream a=new Dream ();
Console. WriteLine (" a ");
return a;
}
}
Public class Animal: fly
{
Public Dream Dream ()
{
Dream a=new Dream ();
Console. WriteLine (" b ");
return a;
}
}
Public class FF
{
Fly activeDoment=null;//here defines an interface fields, sring, int the assignment I know, answer the mouth field I don't understand what meaning, also don't know how to assign a value
//string STR="123";
//int num=3;
Public fly ActiveDocument
{
The get {return activeDoment; }
The set {
ActiveDoment=value;
}
}
}
Public class OrderList : LinkedList
{
Public T FirstValue
{
The get
{
If (First==null)
Return the default (T);
The else
The return First. The Value;
}
}
}
The static void Main (string [] args)
{
OrderList DocumentHistory=new OrderList (a);
FF FF=new FF ();

Dream newDream=new Dream ();
NewDream=ff. ActiveDocument. Dream ();//an error, did not introduce the object instance, how to introduce?
}
}
}

CodePudding user response:

Fly activeDoment=new People ();
Or
Fly activeDoment=new Animal ();
Can, as long as the new object implements the fly interface can assignment,
  •  Tags:  
  • C#
  • Related