61 lines
984 B
C#
61 lines
984 B
C#
public class MyClass
|
|
{
|
|
private int val = 1;
|
|
|
|
// 인스턴스 메서드
|
|
public int InstRun()
|
|
{
|
|
return val;
|
|
}
|
|
|
|
// 정적(Static) 메서드
|
|
public static int Run()
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
public class Client
|
|
{
|
|
public void Test()
|
|
{
|
|
// 인스턴스 메서드 호출
|
|
MyClass myClass = new MyClass();
|
|
int i = myClass.InstRun();
|
|
|
|
// 정적 메서드 호출
|
|
int j = MyClass.Run();
|
|
}
|
|
}
|
|
|
|
// static 클래스 정의
|
|
public static class MyUtility
|
|
{
|
|
private static int ver;
|
|
|
|
// static 생성자
|
|
static MyUtility()
|
|
{
|
|
ver = 1;
|
|
}
|
|
|
|
public static string Convert(int i)
|
|
{
|
|
return i.ToString();
|
|
}
|
|
|
|
public static int ConvertBack(string s)
|
|
{
|
|
return int.Parse(s);
|
|
}
|
|
}
|
|
|
|
|
|
internal class Program
|
|
{
|
|
private static void Main(string[] args)
|
|
{
|
|
string str = MyUtility.Convert(123);
|
|
int i = MyUtility.ConvertBack(str);
|
|
}
|
|
} |