ブランチ
4465 ワード
ブランチは、次の行のコードを制御するプロセスです.三元演算子if文;switch文
三元演算子:
? :
if文は上記のケースを書き換えます.
switchケース:
三元演算子:
class Program
{
static void Main(string[] args)
{
int myInt = 50;
string re=(myInt < 10) ? " "
: " ";
Console.WriteLine("{0}", re);
Console.ReadKey();
}
}
if文は上記のケースを書き換えます.
class Program
{
static void Main(string[] args)
{
int myInt = 50;
if (myInt < 10)
{
Console.WriteLine(" ");
}
else {
Console.WriteLine(" ");
}
Console.ReadKey();
}
}
switchケース:
class Program
{
static void Main(string[] args)
{
int x = 55;
switch (x) {
case 7:
Console.WriteLine("7");
break;
case 8:
Console.WriteLine("8");
break;
default:
Console.WriteLine(" ");
break;
}
Console.ReadKey();
}
}