Read the summary and summary of the knowledge points of learning hard C # Learning notes

Source: Internet
Author: User

I was fortunate in learning hard held the whole hour Rob book activities "Learninghard C # Study Notes" Feedback users, free to send books 5 free to get a "learning hard C # study notes", I (Dream on the journey) although engaged. NET development for many years, but has not been able to learn a good system, especially c#5.0 knowledge, now fortunate to get this book, you can review, consolidate and upgrade, thank learning hard!

After I received the book, it took about two weeks to read, mainly concentrated in the evening and weekend time, because this book is from the shallow into the depth of C # knowledge, although I am not a master, but the early version of C # Knowledge of the basic familiar and mastered, so in the reading of the focus mainly in the back (13 chapters and later), The speed is also compared. I read generally like to do summary and summary, the important points of knowledge in the book will be marked, so that the following review again. Confucius said: Wen so know new, can for the teacher, so I read this book, I feel the need for the book's main points and their usual experience to accumulate some articles, in order to follow up again, also for novice learning reference. The text may be some because of understanding differences exist insufficient, also please comments and guidance, common progress, thank you!

A.. NET Foundation

CLR: Common Language runtime

CTS: Common Type System

CLS: Common Language Specification

CLR-managed code is called managed code, otherwise called unmanaged code

two. Types and Variables

Data types are divided into: value types and reference types

Value types are: Numeric, enumeration, struct

Reference types are: interfaces, classes, delegates, strings, arrays

The value type allocates memory space in the stack and saves the data;

The reference type allocates memory space on the heap and saves the data, and stores the data address in the heap to the stack;

Boxing: Value types are converted to reference types;

Unpacking: The reference type is converted to a value type;

Constants: const identifiers, which must be initialized at the time of declaration and cannot be changed and accessed through the class name;

Variable:

Static: Initialize once and persist in memory space, can read and write repeatedly;

Readonly: Allowed to be initialized only in the constructor of a declaration or in the same class, and cannot be changed elsewhere;

The difference between Static readonly and const:

Static ReadOnly can be initialized in constructors, while Const is not;

Static ReadOnly allocates memory space at run time, while Const allocates memory space at compile time;

Three Operator

operator overloading is defined by the following:

public static type Opearator operator (Type 1, type 2);

Note: The access modifier for operator overloaded methods must be public static

Four Conditions and loops

Conditional statement: 1.if-else 2.switch

Loop statement: 1.while 2.do-while 3.for 4.foreach

Jump statement:

Break: Jump out of a loop or branch; continue: Skips the loop and proceeds to the next loop;

Goto: Jumps to the specified label (not recommended);

Return: Exits the method, and returns or returns the value directly, regardless of depth;

Five Class

Class access Modifiers

Public access is unrestricted, accessible in the same assembly or in other assemblies in the assembly that are referenced within the class;

Private access, limited to within the class;

Protected protected Access, only accessible within the class and within its subclasses;

Internal can be accessed inside and outside of the same assembly class;

Protected internal is accessible within the class of the same assembly and inside its subclasses;

Note: By default, modifiers are not added, which means that they are accessed in internal form

Sealed sealed, can not inherit;

Abstract abstraction, must inherit, if the abstract member in the subclass needs override to rewrite the member;

Statict static seal, can not be instantiated, and can not inherit;

elements defined in a namespace (class, interface, struct, delegate, and so on) cannot be explicitly declared as private, protected, or protected internal

constructor function:

1. can be overloaded; 2. Without a declaration, the constructor for an empty implementation is generated by default after compilation; 3. The constructor name is the same as the class name;

4. no return value;

Function: An object is instantiated by the new corresponding constructor;

Static constructors:

1. You cannot use the access modifier; 2. There is only one parameterless constructor (that is: cannot be overloaded); 3. only once;

function: Initializes a static member of the class;

Destructors:

    1. No access modifier; 2. Only one parameterless destructor can be defined, 3. cannot be overloaded; 4. Automatically called by the garbage collector GC; 5. The structure cannot define the destructor;

Index Indicator:

Definition method: Modifier type this[index parameter list,...]

Note: The index indicator access modifier cannot be static

Six Class differs from struct body

1. A class is a reference type, and a struct is a value type;

2. Structs cannot be initialized when declaring fields, but must be initialized in constructors, and classes are not restricted;

3. The class default parameterless constructor does not exist after the explicit declaration, and the struct cannot be explicitly declared, so it always exists;

4. Structs can only implement interfaces, cannot inherit classes or structs, and classes can inherit classes and can implement interfaces;

5. The structure cannot be declared as Abstact, sealed, Static, and the class can be;

6. Structs can declare objects directly without new, but the unassigned fields are not available, and the class must instantiate the object through new;

Read the summary and summary of the knowledge points of learning hard C # Learning notes

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.