Skip to content

Instantly share code, notes, and snippets.

@mrgarita
Created October 3, 2017 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrgarita/fa6f7c83a82ed61ff2f5f107e293654a to your computer and use it in GitHub Desktop.
Save mrgarita/fa6f7c83a82ed61ff2f5f107e293654a to your computer and use it in GitHub Desktop.
メソッドの途中で終了し呼び出し元に戻る
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