c# 밸류 변수를 레퍼런스 변수로 선언하여 이용하는 방법
메떠드 아규먼트에 ref 키워드를 이용하여 밸류 변수를 레퍼런쓰 변수로 넣는 방법은 많이들 쓰는데 ref는 아래와 같이 선언을 통해서도 유용하게 쓸 수 있다.
class Class1
{
public int Int;
}
private void Form1_Click(object sender, EventArgs e)
{
Class1 class1 = new() { Int = 1 };
ref int int1 = ref _Class.Int;
int1 = 2;
Text = class.Int.ToString(); // 2
}