728x90
class Ch_17
{
public string name;
public int age;
public static string address;
public const string homeTown = "한국";
}
class Ch_18
{
public void time1()
{
Console.WriteLine("20230109");
}
//정적메서드
public static void time2()
{
Console.WriteLine("20230109_2");
}
//참조형 메서드
public static void time3(ref Ch_17 ch_17)
{
ch_17.name = "태권브이";
Console.WriteLine(ch_17.name + "고향 : " + Ch_17.homeTown);
}
public static void time4(out Ch_17 ch_17)
{
ch_17 = new Ch_17();
ch_17.name = "상어";
ch_17.age = 5;
}
}
static void Main(string[] args)
{
Ch_18 ch_18 = new Ch_18();
ch_18.time1();
//정적메소드
Ch_18.time2();
Ch_17 ch_17 = new Ch_17();
Ch_18.time3(ref ch_17);
Ch_17 ch_17_out = null;
Ch_18.time4(out ch_17_out);
Console.WriteLine(ch_17_out.name + "나이 : "+ch_17_out.age);
}
728x90
'c#' 카테고리의 다른 글
[C#] 상속 protected (0) | 2023.01.09 |
---|---|
[C#] 클래스 생성자 오버로딩 (0) | 2023.01.09 |
[C#] Switch와 Enum (0) | 2023.01.09 |
[C#] 구조체 Struct (0) | 2023.01.09 |
[C#] 전역변수와 지역변수 열거형 Enum (0) | 2023.01.09 |