7th WPF C # How to define classes and their interfaces

Source: Internet
Author: User

1. Overview

1.1 Nature of classes and interfaces

Classes and interfaces are used to describe the characteristics of things and thus become programmable things. That is, the physical existence of the things expressed as programming available code. class provides something like a standard template that is instantiated into various objects in the program. Analyze how to generalize things that are physically present as classes and their interfaces.

1.1.1 Abstract classes, derived classes, interfaces

A car, for example, is an abstract class. And cars, trains are also abstract class. Cars, SUVs and buses in automobiles are the specific classes.

Cars, trains are

The number of passengers, the type of tyre and the load of the train are characteristic.

Subordinate derived classes may be suitable for different ancestor derived classes

1. Standard syntax for defining classes and interfaces

1.1 Declaring classes and interfaces

 Public class MyClass [: mybase][. Imyinterface][,imysecondinterface]
{//  Class members.}

1.2 Defining constructors

(1) Default constructor: If undefined, the default constructor is automatically generated

(2) Refactoring function: Multiple refactoring functions can be defined

(3) Execution order of constructors: always start with the most basic class, always call the function before executing

Grammar:

class myclass{   public MyClass () {  //  Default constructor code. }   public MyClass (int.  myInt) {  //  nondefault constructor Code (use S myInt). }}    

1.3 Defining a destructor

When garbage collection is performed, the code in the destructor is executed and the resource is freed. When this function is called, the destructor of the base class is also implicitly called, including the Finalize () call in the System.Object root class.

Grammar:

class myclass{    ~myclass ()    {        //  destructor body.     }}    

Including a call to
In the System.Object root class. This

7th WPF C # How to define classes and their interfaces

Related Article

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.