728x90
//별도 참조할 클래스 생성
public static class Address
{
	public static readonly string data1Car = "1";
    public static readonly string data2Car = "2";
    public static readonly string data3Car = "3";
}

//문자열만으로 변수 호출
for (int c = 1; c <= 3; c++)
{                           
    typeof(Address).GetField($"data{c}Car").GetValue(null).ToString();
}

후....물어볼사람도 없고...독학으로 개발하기는 어렵군요.

머슴살이도 대감집에서 하라고 했는데...하...

 

참조: https://stackoverflow.com/questions/51123075/access-a-static-class-member-using-a-string-variable-string-holds-the-name-of

728x90

+ Recent posts