国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

C#基礎知識記錄一

2019-11-14 13:54:04
字體:
來源:轉載
供稿:網友

 

C#基礎知識記錄一

 

static void Main(string[] args)        {            #region 合并運算符的使用(合并運算符??) 更多運算符請參考:https://msdn.microsoft.com/zh-cn/library/ms173224(v=vs.100).aspx            int? x = null;             //合并運算符的寫法            int? y = x ?? 0;            //三元運算符的寫法:            y = x == null ? 0 : x;            Console.WriteLine(y);             #endregion             #region 多維數組 參考MSDN:https://msdn.microsoft.com/zh-cn/library/2yd9wwz4(v=vs.80).aspx            //二維數組(3行3列)            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);            }            //三維數組:            int[, ,] array3 = new int[3, 3, 3];            //鋸齒數組(更靈活的方式):            int[][] juarray = new int[3][];            juarray[0] = new int[2] { 1, 2 };            //嵌套循環鋸齒數組:            for (int i = 0; i < juarray.Length; i++)            {                if (juarray[i] != null)                    for (int j = 0; j < juarray[i].Length; j++)                    {                        Console.WriteLine("值為:{0}", juarray[i][j]);                    }            }            Console.WriteLine(juarray[0][0]);             #endregion             #region 字符串正則表達式            //------基礎----------------            /* 元字符:  .:表示匹配除換行以外的任意字符  /b:匹配單詞開始或者結束  /d:匹配數字  /s:匹配任意的空白字符             *  ^ :匹配字符串的開始   $ :匹配字符串的結束             *  限定符:  *:重復0次或者多次  +:重復一次或者多次  ? :重復0次或者1次  {n}:重復n次   {n,} :重復n次或者更多次             *    {n,m} :重復n到m次             *   更多關于正則表達式可以參考:   https://msdn.microsoft.com/zh-cn/library/system.text.regularexPRessions.regex.aspx             *   或者是:http://www.survivalescaperooms.com/youring2/archive/2009/11/07/1597786.html  (寫得很清楚)             */            Regex reg = new Regex("http://d");            Console.WriteLine(reg.IsMatch("12321"));            #endregion             #region 集合 List,Queue,Stack,Dictionary ,LinkedList (鏈表)            //舉例:            List<int> list = new List<int> { 1, 2, 3, 4, 5, 6, 7 };            list.ForEach((a) =>            {                Console.WriteLine(a);            });            //或者:            list.ForEach(delegate(int num)            {                Console.WriteLine(num);            });             //隊列:            Queue<int> queue = new Queue<int>();            //向隊列中添加元素:            queue.Enqueue(1);  //從尾部 添加數據            int q = queue.Dequeue();  // 從頭部添加            Console.WriteLine("出隊:{0}", q);            //棧 Stack:            Stack stack = new Stack();            stack.Push(1); //添加            Console.WriteLine("返回棧頂元素:{0}", stack.Peek());//返回棧頂元素            /* 其它:并發集合...                以下幾個為線程安全的集合:iproducerConsumerCollection<T>                ,ConcurrentQueue<T>......BlockingCollection<T>             */            #endregion             #region Linq、動態語言擴展、內存管理與指針            //linq 并行運算AsParallel            var sum = (from f in list.AsParallel() where f < 3 select f);            //動態語言:dynamic            #endregion        }

  

//未完待續...


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湖北省| 凤庆县| 阳原县| 黄龙县| 库车县| 城口县| 深州市| 宣武区| 东莞市| 托克逊县| 合作市| 山东省| 仁布县| 浦东新区| 五莲县| 临沂市| 哈巴河县| 永丰县| 枣阳市| 尤溪县| 金堂县| 许昌县| 安平县| 瓦房店市| 确山县| 贵德县| 昌平区| 阿勒泰市| 青河县| 天柱县| 板桥市| 成武县| 鸡东县| 宁都县| 顺义区| 姜堰市| 甘孜县| 探索| 遂溪县| 湾仔区| 依安县|