【发布时间】:2014-09-09 08:35:22
【问题描述】:
当我尝试调用此函数时,我得到 NullreferenceException,如果代码看起来很奇怪,那是因为我正在从 c++ 翻译成 c#。
public class MyPlayer_t
{
int pLocal;
public int Team;
public int Health;
public float[] Position = new float[3];
public void ReadInformation()
{
pLocal = Mem.ReadInt(Client + playerBase);
Team = Mem.ReadInt(pLocal + teamOffset);
Health = Mem.ReadInt(pLocal + healthOffset);
for (int i = 0; i < 3; i++)
{
Position[i] = Mem.ReadFloat(pLocal + Pos);
}
}
}
MyPlayer_t MyPlayer;
// This is how I call it
MyPlayer.ReadInformation();
【问题讨论】:
标签: c# class nullreferenceexception