「C#」静的メソッド(static method)を使うサンプル
構文
public static 戻り値の型 methodname(){
some code
}
サンプルコード
using System;
namespace ProjectAbc
{
class StudyDemo
{
static void Main()
{
CftDemo.FuncA();
CftDemo tt = new CftDemo();
tt.FuncB();
}
}
public class CftDemo
{
public static void FuncA()
{
Console.WriteLine("this is a message");
}
public void FuncB()
{
Console.WriteLine("today345");
}
}
}
結果
this is a message
today345