C # Review

Source: Internet
Author: User

If you have help, please follow me: Lin Now c# Review notes Chapter 1. Variables: Basic data type: byte short int long float a = 6.5f; Double char bool decimal b = 1000.99m; (Signed and unsigned: Signed sign and unsigned can only represent positive numbers int denotes signed first digit indicates the largest number of size: 2 of the 0-+......+2 30 square xuint represents unsigned Some bits represent the largest number of sizes: 2 of the 0-+......+2 31-square-2x+1 reference data type: 1. Built-in data type (some built-in classes in String C #) 2. Custom data type (our own defined Class) constant: const double PI = 3.1415926; Name of the variable: 1. Initials in English, Underline start 2. See the name of Righteousness 3. You cannot use the keyword 4. Use the name and use of the camel-named constant: 1. Not too long 2. All letters capitalized using 1. Data unchanged 2. Frequent use of the Console class: Output: Console.Write () No Line break System.out.print (); Console.WriteLine () newline System.out.println (); Input: Console.read (); Use the input character eg:char gender = (char) console.read (); Returns the Unicode encoding of a character console.readline (); the most commonly used input returns a string of type Console.readkey (); Pause array: Declaration of an array: string[] names; Java:string name[]; Initialization of the array: int[] array = new int[3]{1,2,3};int[] array = new int[]{1,3,2};int[] array = {}; array ascending order: Arra Y.sort (array name), array reversal output: Array.reverse (array name), 1,7,8,4,5,6--->6,5,4,8,7,1 chapter II: Process Control order structure from top to bottom 1. Select structure Condition statement: 1.if () {}2.if () {} Else{}3.if () {}else if () {}......else{} Multiple If selection structure applies to interval judgment 4.if () {if () {}else{}}else{} nested if applicable to layered if score<10-->if geNDEr = ' man ' switch () {} is used for equivalent judgment 1. Parentheses can use the int char string byte short2. There are only statements after each case Must have a break or continue (when our switch selection structure appears in the loop); 2. Loop structure Loop: 1. Analyze whether to include repeat actions 2. Find the loop condition and the loop Operation 3. Select the applicable loop structure 4. Checks if it is possible to exit the loop while () {} First to judge after executing Do{}while () to execute after the judgment is executed at least once for () {} First judgment after execution (cyclic variable initialization--loop condition--cyclic operation--cyclic variable update) for loop generally used for the number of times fixed foreach (data type variable name in array name) The {} foreach loop is used primarily for queries that cannot assign values to arrays (you can assign values to properties in an array of objects) Jump statements: 1.break is generally used for switch selection and interrupt program in loop structure 2.continue is generally used for loop structure end of this cycle Go to the next loop 3.return the processing result of the 1> return method in the method 2> the third: class: Class is an abstract object of an object: The object is the difference between the materialized field and the property of a class: field: The member property of the class is named with an underscore start property: typically represents the characteristics of a specific object Is the encapsulation of the field (get accessor (read only) and set accessor (write only)) value passing and reference passing (ref) value passing does not alter the original data of the value of the reference pass changes the original data parameter: The definition method is the parameter list argument: The parameter list when the method is called is prefixed with ref (ref int score) argument (ref score) using a reference pass argument must initialize the This keyword this represents the object of the current class fourth chapter: String Class 1.string and string can be used to declare a string variable or object but string is C # , and string is not a keyword in C #, you can use 2 as the variable name. In C #, creating a String object without directly declaring it with the New keyword is 3. The comparison of string strings objects in C # is the same as = = and equals () = = Compared to the first address, equals compares content 4. In C #, there are three ways to initialize a string string: 4.1:string answer = ""; Empty string declares a space of length 0 4.2:string answer = string. Empty; Null value 4.3:string answer = NULL; Empty vacuum Nothing has declared a string object but does not allocate space for it in C #, when the object is null, the NullReferenceException (null reference exception) is reported in Java, and when the object is null, it is reported NullPointerException (null pointer exception) object is null, that is, the current object does not exist to determine the null character of three ways: 1.name.length = = 02.name = = String. Empty;3.name = = ""; 4.name = = null;5.string. IsNullOrEmpty (c); Judge whether a string is null or NULL, a common way to return true5.string in one of the cases the length of the C # string is a property other than the method str. Length java:str.length () IndexOf () returns the position of the first occurrence of the character index subscript LastIndexOf () returns the position of the last occurrence of the character index subscript tolower () Gets the lowercase Java of the string: toLowerCase () ToUpper () Gets the uppercase Java:touppercase () Trim of the string () removes the space before and after the string Java:trim () ToCharArray () Returns an array of character types after a string is processed subString (A, A, A, b) A is a representation of a substring from index A that is truncated at a length of java:substring (A, A, a), a starting position, and b for the length of the end position intercept: b-asubstring ( c) C means a substring starting from index c to intercept to the end of the string split (' delimiter ') splits a string into an array of type string with the specified delimiter ("connector", String array name Fuzhou a string type array with the specified connection into a new strings replace ("a", "B") replaces the value of a string type A with B, and uses him to find the number of occurrences of a character in a string. Format (0,,8:C) formats the first bit to represent the index (placeholder) The second digit indicates the alignment of the third digit that represents the data format C currency D decimal F after the decimal point shows several decimal n using a comma separated by the P percent X is the hexadecimal 6. Type conversions: 1. Implicit conversions (automatic type conversions): Data types to Compatible, with small to large occurrences between values (byte short INT long float double char) 2. Display transformations (Coercion type conversions): Data types to be compatible, from large to small occur between numeric values (byte short int long float double char) may lose precision 3. Xxx.parse (string s): Converts a string type of data to another data type commonly used by: Int. Parse (string s) |float. Parse (string s) |double. Parse (string s) |decimal. Parse (string s) | The DateTime.Parse (string s) argument must be of type string. ToString () can convert any type to string type 4. Convert.toxxx (): Convert any data type to and from one another 1. For string type conversions to other type types be sure to match 2. Rounding 3 is possible for conversions between numeric values. Freq used: Convert.ToInt32 () | Convert.tosingle () | Convert.todouble () | Convert.ToString () | Convert.todatetime () 4. Usage: Converted data type variable name = CONVERT.TOXXX (variable to be converted); 

C # Review

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.