C # basic knowledge record 1,

Source: Internet
Author: User

C # basic knowledge record 1,

 

C # basic knowledge record 1

Static void Main (string [] args)

{

# Use of region merge operators (merge operators ??) For more operators, see https://msdn.microsoft.com/zh-cn/library/ms173224 (v = vs.100). aspx

Int? X = null;

 

// Write the merge Operator

Int? Y = x ?? 0;

// Statement of the ternary OPERATOR:

Y = x = null? 0: x;

Console. WriteLine (y );

 

# Endregion

 

# Region multi-dimensional array reference MSDN: https://msdn.microsoft.com/zh-cn/library/2yd9wwz4 (v = vs.80). aspx

// Two-dimensional array (3 rows and 3 columns)

Int [,] array2 = new int [3, 3];

Int [,] arr2 = {1, 2}, {2, 3}, {4, 5 }};

Int [,] arr3 = {1, 2, 3 },{ 2, 3, 4 }},{ 4, 5, 6 }}};

Foreach (var item in arr3)

{

Console. Write (item );

}

// 3D array:

Int [,] array3 = new int [3, 3, 3];

// Sawtooth array (more flexible ):

Int [] [] juarray = new int [3] [];

Juarray [0] = new int [2] {1, 2 };

// Nested cyclic sawtooth array:

For (int I = 0; I <juarray. Length; I ++)

{

If (juarray [I]! = Null)

For (int j = 0; j <juarray [I]. Length; j ++)

{

Console. WriteLine ("value: {0}", juarray [I] [j]);

}

}

Console. WriteLine (juarray [0] [0]);

 

# Endregion

 

# Region string Regular Expression

// ------ Basic ----------------

/* Metacharacters:.: match any character other than line breaks \ B: match the start or end of a word \ d: Match Number \ s: match any blank character

* ^: Start of matching string $: End of matching string

* Qualifier: *: Repeated 0 or multiple times +: repeated once or multiple times? : Repeated 0 times or 1 time {n}: Repeated n times {n,}: Repeated n times or more times

* {N, m}: Repeat n to m times

*

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.