else キーワード
メニューを表示するにはスワイプしてください
else キーワードは、条件が満たされない場合にコードブロックを実行するために使用。
次の例は、条件が満たされない場合に特定のテキストを出力するもの。
main.cs
12345678910111213141516171819using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int x = 5; int y = 7; if(x > y) { Console.WriteLine("x is greater than y"); } else { Console.WriteLine("x is equal or less than y"); } } } }
次の図は、if else 文のフローを説明。
すべて明確でしたか?
フィードバックありがとうございます!
セクション 3. 章 7
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください
セクション 3. 章 7