我总是在以下行中收到此错误消息:
Casttoenum(this.Polygontype);
无法通过嵌套类型“WindowsPhoneGame2.Containerclass.PolygonContainer”访问外部类型“WindowsPhoneGame2.Containerclass”的非静态成员
怎么了?如何从我的 PolygonContainer 中调用公共 void Casttoenum?
解决此问题的最佳方法是什么?
public List<PolygonContainer> PolygonList = new List<PolygonContainer>();
public struct PolygonContainer
{
public float PolygonpositionX;
public float PolygonpositionY;
public float Polygonrotation;
public int Polygontype;
public PolygonContainer(float polygonpositionx, float polygonpositiony, float polygonrotation, int polygontype)
: this()
{
this.PolygonpositionX = polygonpositionx;
this.PolygonpositionY = polygonpositiony;
this.Polygonrotation = polygonrotation;
this.Polygontype = polygontype;
Casttoenum(this.Polygontype);
}
}
public enum Polygontypes
{
PolyState1 = 1,
PolyState2 = 2,
PolyState3 = 3
}
private Polygontypes currentPolygontype;
public void Casttoenum(int state)
{
currentPolygontype = (Polygontypes)state;
WhichPolygon(currentPolygontype);
}
public List<Vertices> Polyglist = new List<Vertices>();
public void WhichPolygon(Polygontypes polyliststate)
{
switch (polyliststate)
{
case Polygontypes.PolyState1:
Polyglist = list1;
break;
case Polygontypes.PolyState2:
Polyglist = list2;
break;
case Polygontypes.PolyState3:
Polyglist = list3;
break;
}
}