Today is the last day to learn C # process-oriented

Source: Internet
Author: User

Today, after studying the process, it may be written as those, fixed, but the program is determined by its own ...

Today I learned how to invoke a method that exists in the. NET Framework, and there are a lot of things that you might want to use in the future, but I only know them today.

<1>, Max (), Min min (), average average (), and Sum (), transform to array array (), copy Clone ();

<2>, convert to uppercase: ToUpper (); Convert to lowercase tolower ().

<3>, String intercept, Substring (5,4): The first argument is where to start the interception, the second parameter is the number of bits from the first parameter to the beginning of the intercept;

IndexOf ("0"): The inside parameter is the string to intercept, but the output time is the index, that is, the character in the first;

LastIndexOf ("0"): This method retrieves the string to be output from the back, but at the output time the output is also indexed, and the index is still retrieved from the previous start.

<4>, substitution of strings: replace ()

<5>, add delimiter: String. Jion ("|", STRs), the first parameter is the delimiter to be added, the second parameter is the name of the array;

Remove space: trim ();

Remove the left space: LTrim ();

Remove the space on the right: RTrim ().

<6>, determines whether it is empty: string. IsNullOrEmpty ()

<7> When you do not know why type time, use the conversion method: TryParse ();

intint. Tryparms (Console.ReadLine (), out num)

The first argument is the string to be converted, and the second is the converted result.

Examples of the use of <8>,params are as follows:

classProgram {Static voidMain (string[] args) {            //Enter a person's name, phone number, ID number, home address, and age method to implement the method .Information ("Rocky","183401412747","410102","Haidian District Five crossing", -);        Console.readkey (); }        Static voidInformation (stringNamestringPhonestringIdstringAddressintAge//political appearance Marriage no family members national appearance height weight QQ mailbox Fixed telephone{Console.WriteLine ("Hello, everyone! I am {0}, my phone number {1}, my id card {2}, my address {3}, my age is {4}", name, phone, ID, address, age); }

Difference:

classProgram {Static voidMain (string[] args) {               //Enter a person's name, phone number, ID number, home address, and age method to implement the method .Information ( -,"Rocky","183401412747","410102","Haidian District Five crossing");        Console.readkey (); }        Static voidInformation (intAgeparams string[] info)//multi-parameter params[keyword] array number of names 2: All pamrams decorated with the last one must be placed in the method parameter list{Console.WriteLine ("Age {0}, name {1}, phone {2}, id {3}, address {4}", Age, info[0], info[1], info[2], info[3]); }    }

From the above example, it is easier to know the use of the params, using the params must be the same type, and in the form of an array, placed on the last side of the parameter, the params can only be used once in a method.

<9>,readonly read-only keyword, which means that only the method or variable can be read after the keyword is used. Example: ReadOnly int A; Read-only keywords

The use of <10>,var airs, which is used to infer the type, is used by the program to determine what type of operation it is running (strongly typed, weakly typed), which can only be defined within a method.

classProgram {Static voidMain (string[] args) {            varA =5; varb =3.1415926; varc =13.78f; varD =9.3456789m; //var[] array = {1,3,4,5,6,7,8};             varstr ="123456";            Console.WriteLine (str);        Console.readkey (); }    }

The example above uses the var keyword time to annotate the array, because the user cannot be used in the array, and the possible type is the int,double,float,decimal,string type.

Today in the cloud and data college teachers under the leadership of the study of these content, I feel C # syntax is so, it is not difficult, maybe this is just beginning to learn it, has not touched the east of the Cheonan, I ah continue to work hard, study hard, for their own refueling!!!

Today is the last day to learn C # process-oriented

Related Article

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.