本章节主要来讲解关于运算和类型转换的一些问题。

5.1 条件运算符

条件运算符(?:)也成为三元运算符,也就是if..else结构的简化形式。其语法:condition? true_value:false_value下面给出列子来

            int x = 1;
            
string s = x + " ";
            s 
+= (x == 1 ? "Man" : "Men");
            Console.WriteLine(s);

相关文章:

  • 2022-12-23
  • 2022-01-20
  • 2021-05-29
  • 2021-11-27
  • 2021-07-08
  • 2021-07-02
  • 2022-12-23
  • 2021-05-21
猜你喜欢
  • 2022-01-15
  • 2022-02-01
  • 2021-11-05
  • 2021-10-17
  • 2021-09-14
  • 2021-08-26
相关资源
相似解决方案