C # Fourth session

Source: Internet
Author: User

The new knowledge of this class is mainly the key word

Interface

The Chinese translation is an interface, which can be understood as a class, but only the function name and not the specific implementation.

It is not the function of the class, but the use of a "protocol".

This interface is used to contract what functions are required to be called.

When you are going to inherit a interface, you have to implement all of the functions that are required, which is the use of interfaces.

about the specific definition

Interface interface-name [:base-inteface-list] {        interface  Body}

This section of the PPT of the code is relatively clear, then no change

Where attributes is the nature: optional, plural can be.

Access-modifiers:

Access modifiers: optional; complex numbers available; Public, internal, private, protected,protected internal;default:internal

Interface is the key word for interface.

Interface-name is the interface name

[: Base-inteface-list] is a list of interface base classes: optional, plural;

Interface body (cannot have access modifier): Just a signature that defines the method and properties of the interface, and the actual implementation is written in the class using the interface

Again, note that only the signature of the function in the interface class does not have a specific implementation, and the specific implementation is written in the derived class

Note that a class can inherit multiple interfaces, and an interface can inherit multiple interfaces. A number of excuses can be listed later

However, when a class inherits two/more interfaces with the same name function, pay attention to the inheritance.

  Public classdocument:istorable, Italk { PublicDocument (strings) {...;} //Make read virtual      Public Virtual voidRead ()//Implicit inheritance istorable{...;}  Public voidWrite () {...;} voidItalk.read ()//Explicit Inheritance{...;}  Public voidTalk () {...;}}

Code as above. Note explicit implicit differences

And then I talked about the encapsulated (data structure) in C #. ) is used

arrays, etc.

An additional multidimensional array definition is attached. Take int as an example

int New int [2,3];

General form:
new type[x,y,z]; // 3-D

Let's talk about the experiment.

The first on-machine experiment mentioned a lot of knowledge that we haven't talked about yet.

The first is how to write a form program

Because the presence of Visual Studio makes the interface design like a jigsaw puzzle, just drag and drop the required parts from the Toolbox

It's simple, but there's a piece of knowledge that involves invoking another program in one program.

I'm using process to start my console application with a single session.

Because the first time the writer was born, and later to exercise more

C # Fourth session

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.