RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
十二、流程控制之条件运算符
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _12.流程控制之条件运算符
{
    class Program
    {
        static void Main(string[] args)
        {
            /**
             * 三元运算符也称条件运算符
             * 
             * 其语法:
             *   ?  : 
             *  
             * 其执行过程如下:
             * 计算表达式的值,如果为true,则执行resultTrue表达式,否则执行resultFalse表达式。
             * 
             * 执行条件运算符会得到一个返回结果。
             * 
             */
             
            // 使用条件运算符求出三个整数中的最大值。
            
            int max, a = 6, b = 5, c = 7;
            
            max = (a > b) ? a : b;
            max = (max > c) ? max : c;
            Console.WriteLine("a = {0}, b = {1}, c = {2} 三个整数中的最大值为: {3}", a, b, c, max);
            
            Console.ReadKey();
        }
    }
}

名称栏目:十二、流程控制之条件运算符
当前URL:http://cqwzjz.cn/article/iidsgj.html