다음과 같은 클래스에서 함수를 정의했습니다. 이 클래스에서 값은 이미 계산 된 값 목록에서 찾을 수없는 경우 조회되거나 계산됩니다.클래스에서 객체 참조 오류가 발생했습니다.
새로 계산 된 결과는 목록에 저장되므로 이후 호출에서 조회 할 수 있습니다.
문제는 컴파일러가 내가 그것을 할 방법을 좋아하지 않는 나에게
An object reference is required for the non-static field, method or property App.GetGoodFontSize(string, Size).
을 내가 컴파일러는 제안을 이해하지 않는 이야기이다. 어떤 객체 참조가 의미합니까?
감사합니다.
public class App : Application
{
private List<udt> _list = new List<udt>();
private class udt
{
public int iLen { get; set; }
public Size nSize { get; set; }
public double FontSize { get; set; }
}
public double GetGoodFontSize(string uText, Xamarin.Forms.Size uTextRect)
{
for (int i = 0; i < _list.Count; i++)
{
if ((_list[i].iLen == uText.Length) && (_list[i].nSize == uTextRect))
{
return _list[i].FontSize;
}
}
int iBest = 100;
for (int i = 100; i > 6; i--)
{
Size nSize = GetTextSize(uText, i);
if (nSize.Width <= uTextRect.Width)
{
if (nSize.Height <= uTextRect.Height)
{
iBest = i;
break;
}
}
}
udt n = new udt();
n.iLen = uText.Length;
n.nSize = uTextRect;
n.FontSize = iBest;
_list.Add(n);
return iBest;
}
대부분의 경우는이 라인에있다. 그것은 무엇이며 어디에 있습니까? – CodingYoshi