초기 커밋.
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,43 @@
|
||||
class CSVar
|
||||
{
|
||||
//필드 (클래스 내에서 공통적으로 사용되는 전역 변수)
|
||||
int globalVar;
|
||||
const int MAX = 1024;
|
||||
|
||||
public void Method1()
|
||||
{
|
||||
// 로컬변수
|
||||
int localVar;
|
||||
|
||||
// 아래 할당이 없으면 에러 발생
|
||||
localVar = 100;
|
||||
|
||||
Console.WriteLine(globalVar);
|
||||
Console.WriteLine(localVar);
|
||||
}
|
||||
}
|
||||
|
||||
class CSVar2
|
||||
{
|
||||
// 상수
|
||||
const int MAX_VALUE = 1024;
|
||||
|
||||
// readonly 필드
|
||||
readonly int Max;
|
||||
public CSVar2()
|
||||
{
|
||||
Max = 1;
|
||||
}
|
||||
|
||||
//...
|
||||
}
|
||||
|
||||
internal class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
// 테스트
|
||||
CSVar obj = new CSVar();
|
||||
obj.Method1();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user