C # Object-oriented (basic knowledge)

Source: Internet
Author: User

Object-oriented: Class,class is the user-defined type;

Class: User-defined reference type;
Three main features: encapsulation, inheritance, polymorphism;

In the solution, right-click to add Class;
Class can be written in structure, enumeration, function;

What each shape means in C #

Property----------Small Wrench
Member Variable------box
Method (function)--cube

Encapsulation :---Properties
member variable; object;
Public modifier--can be accessed across classes;

Static in the main function does not belong to any class, so the class must be called;

overloads of the method:
A function has multiple meanings;
The same name, when the parameters are different;
ctrl+shift+ spaces


Static member of class: (Static)
Is that you don't need to initialize
Static is the meaning of statics;
Do not go through the object, directly through the "class" walk;
In a handout: distinguish the next area in a for loop


Namespaces:
namespace name----namespaces;
Using is the meaning of application;
Class Library:


constructor function:
Each class defaults to a constructor with the same name without a parameter and no return value;
The process of creating objects, new initialization, is actually the process of invoking the constructor of the class;
Example: Public name () {} This is the default no parameter no return value constructor;
Constructors can also be overloaded;

Four modifiers:
Public: can be used across namespaces and requires reference to namespace names;
Private: Privately, only in the current class of their own access;
Protected: Protected, able to cross classes, can be accessed in their own subclasses;
Internal (internal, default) the current namespace is used;


inheritance : The relationship between a class and a class (parent-child relationship)
Subclass inherits the parent class, the child class has the public properties and methods of the parent class;
A subclass can inherit only one parent class, and a parent class may have multiple subclasses;
Subclass objects can be transferred directly to the parent class, but the parent can only "go back" to the corresponding subclass;
If a subclass is turned into a parent class, the parent object cannot have properties and methods of the child class;

The inheritance is the public class;

The difference between a reference type and a value type:
When assigning a value:
int a = 1;
int B = a;//a and B are two completely different

Class1 dataa = new Class1 ();
Class1 datab = new Class1 ();//Completely different

Class1 data1 = new Class1 ();
Class1 data2 = Data1;//data2 is just a shortcut to data1;

Class Tiger:animal (Inheritance relationship expression)
{

}
Inherited overloads:
Subclasses inherit the methods of the parent class, and overloads can occur when different parameters of the same name are present;
If the same parameter is associated with the parent class: The subclass only calls its own method;
There is also a virtual method (in the last few minutes of the other class video 6), after the child class is converted to the parent type, the subclass method is still called;

Polymorphism: With inheritance, there are many states. Diversity of sub-categories.


abstract base class and interface: The subclass must inherit the property or method of the parent class;
Abstract classes cannot create objects; they cannot be used directly in the main function, but only by subclasses;
is to add an abstract before class

Abstract methods and properties must be written in abstract classes;
Abstract method Direct ";" end, inside not write content, through subclasses must write
Override to achieve;

Abstract Properties:
Public abstract String Name
{
Get
Set
}

interface : (equivalent to a subclass of the master, a subclass can have more than one interface)
public interface Xixing
{
void Quyu ();
}
Above is a xixing interface, inside there is a function Quyu ();

Once a subclass is connected to an interface, it must also use functions within this interface;

WinForm

Partial Division;
All controls are classes;
All attributes are encapsulated;
This is the class in which I am speaking;


The delegate is outside the class;
Addition and subtraction of delegate variables:
The addition of a delegate variable: when the two delegate variables are added, they are executed successively.
Finally returns the value of the latter delegate variable;
Subtraction of the delegate variable: executes the delegate variable preceding the minus sign, and the delegate variable after the minus sign is not executed;

Class Tiger:animal (Inheritance relationship expression)
{

}
Inherited overloads:
Subclasses inherit the methods of the parent class, and overloads can occur when different parameters of the same name are present;
If the same parameter is associated with the parent class: The subclass only calls its own method;
There is also a virtual method (in the last few minutes of the other class video 6), after the child class is converted to the parent type, the subclass method is still called;

Polymorphism: With inheritance, there are many states. Diversity of sub-categories.


Abstract base class and interface: The subclass must inherit the property or method of the parent class;
Abstract classes cannot create objects; they cannot be used directly in the main function, but only by subclasses;
is to add an abstract before class

Abstract methods and properties must be written in abstract classes;
Abstract method Direct ";" end, inside not write content, through subclasses must write
Override to achieve;

Abstract Properties:
Public abstract String Name
{
Get
Set
}

Interface: (equivalent to a subclass of the master, a subclass can have more than one interface)
public interface Xixing
{
void Quyu ();
}
Above is a xixing interface, inside there is a function Quyu ();

Once a subclass is connected to an interface, it must also use functions within this interface;


1110:
WinForm
Partial Division;
All controls are classes;
All attributes are encapsulated;
This is the class in which I am speaking;


The delegate is outside the class;
Addition and subtraction of delegate variables:
The addition of a delegate variable: when the two delegate variables are added, they are executed successively.
Finally returns the value of the latter delegate variable;
Subtraction of the delegate variable: executes the delegate variable preceding the minus sign, and the delegate variable after the minus sign is not executed;

C # Object-oriented (basic knowledge)

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.