C # Study Notes (2)

Source: Internet
Author: User

1. Object-oriented

 

1. User Interface: a specification.

1) method definitions of interfaces cannot be implemented.

2) If the interface is inherited, the interface definition must be fully implemented.

 

Interface Definition

 

Interface Name

{

// Code // access public by default

}

 

Multi-inheritance Interface

Public Class Name: parent, interface, interface2 // separated by commas

 

 

2. keyword is: used to check whether an object is compatible with the given object type.

 

If (obj is person)

{

}

 

3. keyword as: used for object conversion. If the operation fails, null is returned. // as does not cause an exception.

 

4. Keyword New: Used to overwrite the new members of the parent class and has no relationship with the parent class. It is generally used to avoid polymorphism.

 

2. Delegate and event)

1. Delegate

Generally, three steps are required for delegation.

1. Define Delegation

Access modifier delegate return type funname (parameter list) // funname function name

2. instantiate the delegate

Funname name = new funname (function parameter) // The function is a function that returns the same list of parameters as the delegate.

3. Call the delegate

Name (parameter list );

Similar to C ++ function pointers. The delegate can be considered as a type with parameters.

The delegate itself is a static type. The delegate is called by class name.

2. Events.

 

Events are implemented by delegation.

Generally, events are divided into four steps:

1. Define the event proxy (define delegation)

2. Define an event, for example, a public event Delegate name event name

3. Name of the trigger event ();

4. Associated events such as: event name + = new delegate name (function 1); // function 1 is called every time an event is triggered.

 

Using Structure

 

Using ()
{

} // When the object is out of scope, the using structure will automatically call dispose (); Delete the object

 

Filestream // stream to access files.

 

 

 

 

 

 

 

 

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.