Created
October 3, 2017 06:36
-
-
Save mrgarita/fa6f7c83a82ed61ff2f5f107e293654a to your computer and use it in GitHub Desktop.
メソッドの途中で終了し呼び出し元に戻る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace メソッドの途中で終了し呼び出し元に戻る | |
{ | |
class Program | |
{ | |
static void SayHello(string name) | |
{ | |
if(name == "ドラえもん") | |
{ | |
return; // メソッド SayHello を抜けて呼び出しもとに戻る | |
} | |
Console.WriteLine("こんにちは" + name + "さん!"); | |
} | |
static void Main(string[] args) | |
{ | |
Console.Write("Name? "); | |
string name = Console.ReadLine(); | |
SayHello(name); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment