0

我收到一个我无法弄清楚的错误。我尝试了谷歌和 SO,但无济于事......

这是我的代码:

for (int i = 0; i <= dctConvertedJSON.GetUpperBound(0); i++)
{
    foreach (KeyValuePair<string, string> kvp in dctConvertedJSON(i))
    {
        string strKey = kvp.Key;
        string strValue = kvp.Value;
        Debug.WriteLine("Key: " + strKey.ToString + Constants.vbTab + " Value: " + strValue);
    }
}

foreach我收到一个错误dctConvertedJSON消息:

Error: 'dctConvertedJSON' is a 'variable' but is used like a 'method'

我在做什么(或不做什么)导致这个错误?

4

1 回答 1

4

您应该将其更正为:

dctConvertedJSON[i]

所以代码是:

for (int i = 0; i <= dctConvertedJSON.GetUpperBound(0); i++)
{
    foreach (KeyValuePair<string, string> kvp in dctConvertedJSON[i])
    {
        string strKey = kvp.Key;
        string strValue = kvp.Value;
        Debug.WriteLine("Key: " + strKey.ToString() + Constants.vbTab + " Value: " + strValue);
    }
}
于 2013-10-25T19:11:58.283 回答