我正在使用以下代码:
private Dictionary<string, user> totalUsers = new Dictionary<string, user>();
“用户”类的相关部分
private Dictionary<DateTime,string> killerField;
public Dictionary<DateTime,string> killedPlayers
{
get
{
return this.killerField;
}
set
{
this.killerField = value;
}
}
我如何尝试执行此操作
totalUsers[playerName].killedPlayers.Add(DateTime.Now, dyingPlayer);
但我收到一个错误:
"Object reference not set to an instance of an object"
为什么它不起作用?
提前致谢。