. NET Chapter I. Summary

Source: Internet
Author: User
Tags mathematical functions

One,
1.CLR common Language Runtime. FCL Base Class Library
2.NET is a hardware-independent program execution platform, the implementation of this machine through two compilation, the execution process is as follows.

3. Type inferred var keyword can automatically recognize variables
such as Var n=0; int n=0; equivalence
4. The break statement can jump out of a looping statement. Continue jumps out of the current loop instead of completely jumping out of the loop.


Ii. common operations for strings
1.. Length is the ability to get the lengths of strings.

2. Strings can be added directly with +, or they can be added with StringBuilder class real member implementations.
Sb. Append ();//sb as Object

3. Intercept part of a string variable. Substring (starting position, intercept position)
String S1=str. Substring (0,2)

4.Split usage
1. Splitting with a single character
String str= "AAA,BBB,CCC";
string []sarray=str.split (', ');//gets, splits the individual strings
foreach (String i in Sarray)
{
Response.Write (i.ToString () + "<br>");
}
Output
Aaa
Bbb
Ccc

2. Separating with multiple characters
String str= "Aaajbbbscccjdddseee";
string []sarray=str. Split (New char[2]{' J ', ' s '});//obtained with ' j '. ' S ' separated by each string
foreach ()
{
......
}
Output Result:
Aaa
Bbb
...

3. Splitting with strings
Using system.text.regularexpreesions;//Reference

String str= "AAAJSBBBJSCCC";
String[] Sarray=regex.split (str, "JS", regexoptions.ignorecase);//Get a ' JS ' divider

Three, convert 123456789 to 12-345-6789
String A= "123456789"
A=a.insert (5, "-"). Insert (2, "-");

Iv. methods for obtaining random numbers
Random r=new random ();
int N1=r.next ();//Returns a random non-negative integer

V. Type of conversion
Convert.to....,int.parse (), INT32. Parse (), etc.;
INT32. Parse () Superior performance

Six, commonly used mathematical functions
Math.ceilling ();//returns the smallest integer greater than or equal to the specified number
Cases
Math.ceilling (0.00);//0
Math.ceilling (0.40);//1
Math.ceilling (0.60);//1
Math.floor (); Returns the smallest integer less than or equal to the specified number


Object-oriented focus inheritance delegate event reflection

I. Inheritance

Inheritance rules
1. Derived classes inherit all members of the base class. If the base class B is inherited by a, then C inherits the members of a when they inherit B. But construction,
Functions and destructors cannot be inherited.
2. Derived classes can only inherit from one class, with multiple inheritance through an interface

Accessing base class Members
1. When a derived class accesses a base class constructor, the constructor of the derived class is called, and the other calling procedure
2. Call the base class method in the method of the derived class base.< the base class method name >;base. SayHello ();
3. ((ParentClass) child). SayHello ();//Explicit type conversion

4.new can hide the base class method;

Abstraction and Sealing
Sealed class modifier sealed, sealed and not inherited by other classes

Abstract classes are classes that are specifically written for inheritance, and modifiers are abstract
1. Abstract classes cannot be instantiated, abstract methods do not have specific execution code, and code is overridden in non-abstract derived classes. Derived class methods
Re-add modifier override (method of abstract class with the same name)
2. If you do not want to write the method as an abstract class, but the method is not specifically implemented in the base class, it is overridden in a derived class.
The method is declared with the modifier virtual function, and the code is rewritten by override in the inheriting class;

Multiple inheritance, C # does not allow inheriting multiple classes, but allows inheritance of multiple interfaces;

What is an interface? interface modifier interface; interface is a method defined only, with no specific content. To define a method in a class that references an interface

3. If you inherit multiple interfaces, the interface has a method with the same name. When the interface is implemented

It is necessary to cast the conversion to the appropriate interface type when invoking the method of the interface.

You cannot invoke an interface method without casting.

Implementing multiple interfaces with different name methods preceded by the public modifier

. NET Chapter I. Summary

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.