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
*