a++和++a 的区别

时间:2017-10-23 21:16:23   收藏:0   阅读:300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 10;
            int b = 11;
            Console.WriteLine("a++="+a++);
            Console.WriteLine("++a="+ ++a);

            Console.WriteLine("b--=" + b--);
            Console.WriteLine("--b=" + --b);

        }
    }
}

  运行结果让人很惊讶

技术分享

a++程序运行到这行时 a的值不做改变的 当程序运行下一行a的值加一;

++a当程序运行到这一行a的值就直接改变

 

原文:http://www.cnblogs.com/cai-yuan/p/7718881.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!