?:运算符号:条件运算符;
condition ? first_expression : second_expression;
如果条件为 true,则计算第一表达式并以它的计算结果为准;如果为 false,则计算第二表达式并以它的计算结果为准。只计算两个表达式中的一个。
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1 ?:运算符号:条件运算符;
2 condition ? first_expression : second_expression;
3 如果条件为 true,则计算第一表达式并以它的计算结果为准;如果为 false,则计算第二表达式并以它的计算结果为准。只计算两个表达式中的一个。
4
5 复制代码
6 // cs_operator_conditional.cs
7 using System;
8 class MainClass
9 {
10 static double sinc(double x)
11 {
12 return x != 0.0 ? Math.Sin(x)/x : 1.0;
13 }
14
15 static void Main()
16 {
17 Console.WriteLine(sinc(0.2));
18 Console.WriteLine(sinc(0.1));
19 Console.WriteLine(sinc(0.0));
20 }
21 }
22
23
24 输出
25
26 0.993346653975306
27 0.998334166468282
28 1
29
再看代码:
return ((((n / i) > 0.98 ? 0.98 : (n / i)) * 100).ToString() + "0000").Substring(0, 2).Replace(".", "") + "%";
继续:
this.group_x = dt.Tables[0].Rows[0]["group_x"].ToString().Trim()=="1"?"单选":"多选";