C # Basics Summary

Source: Internet
Author: User

This is my first blog, I have learned some of the summed up, if there is a mistake, please contact me to change

1, naming conventions
field, the local variable is named by Camal, which is the first letter lowercase, the other uppercase.
The type, method, and attribute are named by Pascal.
2, annotation method
Line Comment://
Documentation Notes://
Block Comment:/* */
3, pre-defined type
Simple Type: 11 Types of Numbers (sbyte,byte,short,ushort,int,uint,long,ulong,double,decimal,float), Char,bool
Non-Simple type: string,object,decimal
4, user-defined type
Class,delegate,interface,enum,struct,array
5, value type and reference type
Value type: struct,enum, all numeric types
Reference type: Class,delegate,interface,array
6, access modifier
Private (accessible only from within the class)
Internal (default, can only be accessed centrally in the assembly)
Protected (only subclass access)
Internal protected (accessible from assemblies and subclasses)
Public (can be accessed anywhere)
7, class member
Field: Used to store data, can be any type, can be automatically initialized to the default value
Properties: Readable properties, writable properties, automatic properties, readable writable properties
Method: Parameter type, ref out params
8, keyword
This: calling the class member; displaying the call constructor
Base: Call base class member, call base class constructor
9, type conversion
Implicit conversions: Low-level numeric types become high-bit numeric types, int to long, classes or interfaces can be converted to object, implemented interfaces, classes;
Display conversion: Convert method, () target (the conversion failure throws an exception); as operator (conversion failure does not throw an exception, return null); You can use checked (failure throws an exception), unchecked statement checks for overflow
Boxing: Value type to reference type
Unpacking: Reference type to value type (loaded, unpacking can consume performance and should be avoided)
10, Delegate
System Delegate,action<> no return value
Func<> has a return value
11, Exception
With a try catch or try Catch finally or try finally
A try can have only a finally, can have multiple catch anyway, finally will be executed
Catch if there is no catch for the exception, the stack is expanded to look for a matching catch, none throws an exception

C # Basics 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.