Abstract class Abstraction:
Abstract classes and abstract methods can be identified with the abstract keyword. is a class or method that is not fully defined. Therefore, you cannot instantiate the operation directly.
Because he is not fully defined, it cannot be sealed with the sealed keyword.
Abstract methods do not include program bodies:
Public abstract class Student
{
Abstract method with no program body
public abstract void Getstudentid ();
Sub-class accessible fields
prodected int i;
Defining the properties of I
public int I
{
Get
{
return i;
}
}
}
Abstract methods for implementing abstract classes in inheriting classes
public class Ah:student
{
public AH (int a)
{
This.i=a;
}
public override void Getstudentid ()
{
Console.WriteLine (i.ToString ());
}
}
Interface interface:
A unified planning interface. Used to define a specification (such as the identification of a method) that needs to be adhered to in a subclass.
Abstract classes cannot be instantiated directly.
The identity of a method, property, or indexer can be defined in an interface.
All members in an interface have the default properties of public and abstract. The methods in the interface must be implemented in subclasses.
A class can ":" Inherit multiple interfaces, and an interface can inherit multiple interfaces.
public interface First
{
Indexer
String This[int i]
{
Get
Set
}
Method
int fun (int t);
Property
String J
{
Get
Set
}
}
Trivia (V): Abstract classes & Interfaces