• i++、++i 、i--、--i


    总结:

    i++ 先用后加,

    ++i先加后用;

    i--先用后减,

    --i先减后用;

            //int i = 1;
            //Console.WriteLine(i);//1
            //Console.WriteLine("i++={0}", i++); //1  
            //Console.WriteLine(i);//2
    
            //int j = 1;
            //Console.WriteLine(j);//1
            //Console.WriteLine("++j={0}", ++j); //2
            //Console.WriteLine(j);//2
    
    
            int i = 1;
            Console.WriteLine(i);//1
            Console.WriteLine("i--={0}", i--); //1
            Console.WriteLine(i);//0
    
            int j = 1;
            Console.WriteLine(j);//1
            Console.WriteLine("--j={0}", --j); //0
            Console.WriteLine(j);//0
    
         //++、--的优先级大于+、- //int k = 1; //int k2 = 1 + --k; //Console.WriteLine(k2);//1 Console.ReadKey();


     

  • 相关阅读:
    day14
    day13
    装饰器小题
    day12
    tes..
    1380 没有上司的舞会
    算法模板——KMP字符串匹配
    算法模板——Tarjan强连通分量
    3211: 花神游历各国
    1131: [POI2008]Sta
  • 原文地址:https://www.cnblogs.com/hao-1234-1234/p/6136308.html
Copyright © 2020-2023  润新知