十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
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();
}
}
}