초기 커밋.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,61 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user