「C#」クラスのメソッドを使うサンプル
書式
修飾子 戻り値の型 メソッド名 (引数)
{
return 値;
}
使用例
using System;
namespace Project1
{
class Example
{
//戻り値なし
public void Func()
{
Console.WriteLine("study skill");
}
// 戻り値あり
public string FuncA()
{
return "arkgame";
}
}
class Changfa
{
static void Main()
{
//Exampleクラスの定義
Example ep = new Example();
//Funcメソッドfuncを呼び出す
ep.Func();
//FuncAメソッドを呼び出す
Console.WriteLine(ep.FuncA());
}
}
}
結果
study skill
arkgame