SQL Database Basics-Abstract Classes

Source: Internet
Author: User

Abstract classes that appear only for inheritance, do not define specific content, and only specify what is in it;
Only abstract methods are placed in general abstract classes, and only return types and parameters are specified;
Like what:
People--There are ways to eat and sleep;
Man-Heir abstract class, must realize the main body of eating, sleeping methods;
Woman-Heir abstract class, must be four lines to eat, sleep the main body of the method;

Abstract classes can have ordinary properties, through subclasses to use;

1. Keywords: abstract
2. Abstract classes can contain abstract methods and common methods
3.abstract keywords can define methods as abstract methods, abstract methods can have no function body
4. Abstract classes cannot be instantiated, and abstract classes are primarily a base class, allowing other classes to inherit.
5.sealed and Abstract keywords cannot appear at the same time
6. If a subclass inherits from an abstract class, all of the abstract methods must be implemented in the child class
7. If the subclass does not have an abstract method that implements the parent class, the subclass must be an abstract class
8. If a class contains abstract methods, then the class must be an abstract class

Abstract methods must be abstract classes.
Abstract class, there is not necessarily an abstract method

Public Abstruct Ren
{
Public abstruct Void Eat ();
Public abstruct Void Sleep ();
}

-----------------------------------------------------------------
Interface:

An extremely abstract class.

Head Office--established rules and regulations (interface)--the company must take attendance of employees

Subsidiary company to follow the company's rules and regulations-the implementation of time-specific attendance-punch
Subsidiary 2--follow the company's rules and regulations--to achieve the specific attendance--roll Call

The difference between an interface and an abstract class:
1. Differences in wording
Keyword: interface
There is no class keyword that starts with I
Do not write public because it is public, do not write the abstract interface inside all are pumping
Elephant's

2. The interface cannot contain ordinary members
3. All classes that inherit the interface must implement the method inside the interface.

Because the team develops, each person is responsible for a module, I only responsible for the basic life part, another person is responsible for the work part, there is also a person responsible for the entertainment activities part;


Public interface Work
{
void Skill ();
void Place ();
}

public interface Sports
{
void Sport1 ();
}

Class Library

There are times when we need to use a class written by someone else.

1. If the class is a source code class. cs File
To get the file to the project, you can choose to add a new item or choose to add an existing item
Introduce the appropriate namespaces

2. If the class is not a source code, but a compiled. dll file (the compiled class library)
Take the file to the project, add reference--browse--Find the. dll file
Introduce the appropriate namespaces

SQL Database Basics-Abstract Classes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.