玖。|ू •̀ω•́ )۶
1 months ago @Edit 1 months ago
【C#】 0331
今日進度:
C# Booleans ←請參考Comparison & Logical
C# If....Else:
if、else、else if、
簡寫句式 □□= (□□)?□□ :□□
.
這個我會!Excel很常用到
latest #16
掰噗~ 正在
1 months ago
(筆記筆記) (p-nerd)
這次有新魔法啦
using System;
namespace 新魔法展開!

class Program
{
static void Main(string[] args)
{
if(______)
{
Console.WriteLine(“_____“);
}
立即下載
else
{
Console.WriteLine(“_____”);
}
}
}
}
玖。|ू •̀ω•́ )۶
1 months ago @Edit 1 months ago
再複習一遍:
<
<=
>
>=
== 等於
!= 不等於
玖。|ू •̀ω•́ )۶
1 months ago @Edit 1 months ago
1. 條件語句:
白話文:如果.....就.....否則.......

if:當條件為True執行指令
else if
【多個判斷】當第一條件不符合則續驗證其他條件、若為True則執行條件後的指令
else:若條件為False則執行另一件事
玖。|ू •̀ω•́ )۶
1 months ago @Edit 1 months ago
-
int time = 22;
玖。|ू •̀ω•́ )۶
1 months ago @Edit 1 months ago
if (time < 10) // if(條件一)
{
Console.WriteLine(“Good morning.”);

else if (time < 20) // else if(條件二)
{
Console.WriteLine(“Good day.”);
else // 否則
{
Console.WriteLine(“Good evening.”);
//
這邊Ouput= Good evening.
玖。|ू •̀ω•́ )۶
1 months ago @Edit 1 months ago
2. If.....Else的簡寫句式:
變數=(條件)?True的指令:False的指令;
A = (B) ? C : D
玖。|ू •̀ω•́ )۶
1 months ago @Edit 1 months ago
int time = 20;
if (time<18) // if(條件)

Console.WriteLine(“Good day.”);
//True指令
}
else
{
Console.WriteLine(“Good night.”);
//False指令
}
簡寫句式↓
int time = 20;
string result = (time<18)?”Good day.”:”Good night.”;
Console.WriteLine(result);
back to top