C# 无法将带[]的索引应用于类型为的表达式?
我犯了这个错误C# 无法将带[]的索引应用于类型为的表达式?,c#,C#,我犯了这个错误 Error 3 Cannot apply indexing with [] to an expression of type 我的问题在这里 if (client["banhours"] == 0) { client["banhours"] = -1; client["banreason"] = "Infinite time."; client["banstamp"] = DateTime.Now.AddYears(100); } if (Ac
Error 3 Cannot apply indexing with [] to an expression of type
我的问题在这里
if (client["banhours"] == 0)
{
client["banhours"] = -1;
client["banreason"] = "Infinite time.";
client["banstamp"] = DateTime.Now.AddYears(100);
}
if (Account.State == Database.AccountTable.AccountState.Banned)
{
if (client["banhours"] != -1)
{
DateTime banStamp = client["banstamp"];
if (DateTime.Now > banStamp.AddDays(((int)client["banhours"]) / 24).AddHours(((int)client["banhours"]) % 24))
Account.State = Database.AccountTable.AccountState.Player;
}
}
客户端是>>>
Client.GameClient 您是否尝试过client.banhours或client.banreason
如果Client.GameClient是一个类,而这些是属性或字段,则不能像数组或字典一样访问它们。什么是客户端?我们可以有更多的代码吗?请发布GameClient的代码什么是GameClient?它来自哪里?为什么你认为你可以使用索引和它?游戏客户端是类,他是在变量和无效大!这个问题无法回答。。我们需要GameClient的代码。是的,我失败了D:但是在旧项目中工作很好,没有错误。无论如何,谢谢我解决了它:D