Can you provide a non-abstract execution method in an abstract class? What about the interface?
A: Abstract classes can be written like this:
Copy Code code as follows:
Public abstract class A
{
public string Getweburl ()
{
return "Jb51.net";
}
Public abstract string Getwebname ();
}
public class B:a
{
public override string Getwebname ()
{
Return to "cloud-dwelling community";
}
}
Run: b b = new B ();
Response.Write (B.getweburl ());
Compilation passes without errors, and the interface itself can contain only members but not concrete implementations, and abstract functions can exist only in abstract classes, so only the signature of the method in the interface, but not the specific implementation, and not abstract functions, for example: C # copy Code
Interface IA
{
String Getweburl ();
String Getwebname ();
}
Second, does the member in the interface have to be implemented by its subclass?
A: Interfaces are a special case of abstract classes, and abstract functions must be overridden by their subclasses, and the members of an interface must be implemented by their subclasses as well.
Can I use the virtual keyword in an abstract class?
A: No, abstract classes can contain only abstract methods and abstract accessors.
Can abstract classes be instantiated?
A: No, you can't.