Understanding of interface of interface in c sharp

  • 2020-05-05 11:45:49
  • OfStack

.are "virtual" and cannot be instantiated, which is why the interface cannot contain fields -- member variables.
2. Because the interface is virtual, so the index, property, time and so on in the interface can only be declared, and can not be implemented in the interface, how to achieve is a derived interface or derived class.
3. All have the nature of template. If an interface or class inherits from an interface, it will automatically have the characteristics of the integrator (including indexes, properties, functions, practices, etc.).
4. Interfaces support multiple inheritance, while in C #, classes support single inheritance, and interfaces actually represent a kind of carrying capacity.
Here is a simple definition of an interface:

interface  
SampInterface1  
{  
    string   
    this[ int index]  
    {  
        get;  
        set  
    }  

    event EventHandler Event;  
    void  Find( int value );  
    // Notice there is no   
    {  
    }  
    string Po  
    int  
    {  
        get;  
        set  
    }  

} 

The interface above defines an index this, a practice Event, a method Find, and a property Point.

public interface SampIneterface:SampIneterface1{   
pravite  int a=1;  
void find (int value)  
{  
a+=value;  
}  
event EventHandler Event;  
protected void onEvent()  
{  
if(Event=null)  
{return Event(this.System.EventAgrs.Empty;)}  
}  
}

Related articles: