诗情寻知己
揽几缕、轻挽起,暮暮朝朝与君语。
static void Main(string[] args)
        {
            int j = 0;
            Console.WriteLine("++ j =>" + (++j));
            //++ j => 1

            int s = 0;
            Console.WriteLine("s++ =>" + (s++));
            //s++ =>0

            int k = 0;
            Func<int, int> f = (int input) => {
                try
                {
                    k = 10 / input;
                    k++;
                    return k;
                }
                catch (Exception)
                {
                    ++k;
                    return k;
                }
                finally
                {
                    Console.WriteLine("finally,key "+ k +" =>" + (k++) );
                }
            };

            Console.WriteLine("key 0 =>" + f(0));
            Console.WriteLine("key 10 =>" + f(1));
            //finally,key 1 =>1
            //key 0 =>1
            //finally,key 11 =>11
            //key 10 =>11


            int index = 0;
            List<string> colors = new List<string>() { "red", "yellow", "blue" };
            var cdata = colors.Where(c => {
                index++;
                return !c.StartsWith('y');
            }).ToList();

            Console.WriteLine("index =>" + (index));
            Console.WriteLine("cdata Count=>" + (cdata.Count));
            Console.WriteLine("index =>" + (index));

            //index => 3
            //cdata Count=>2
            //index => 3

  

posted on 2023-04-18 15:53  诗情寻知己  阅读(12)  评论(0编辑  收藏  举报