Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法将带[]的索引应用于类型为的表达式?_C# - Fatal编程技术网

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