非静态字段,方法或属性'System.Collections.DictionaryEntry.Key.get需要对象引用

时间:2016-02-29 14:46:34

标签: c# dictionary hashtable namevaluecollection

我的下面的方法是抛出一个错误:

  

错误205非静态字段需要对象引用,   方法或属性'System.Collections.DictionaryEntry.Key.get

 static string GetConfigValue(NameValueCollection tempCollection)
    {

        string paymentDisposition = string.Empty;

        Hashtable tempCollectionHash = new Hashtable();
        foreach (string key in tempCollection.Keys)
        {
            tempCollectionHash.Add(key, tempCollection[key]);
        }


        if(tempCollectionHash.ContainsKey("Cancellation"))
            paymentDisposition = (string)tempCollectionHash["Cancellation"];

        foreach (DictionaryEntry entry in tempCollectionHash)
        {
           if (DictionaryEntry.Key.Contains(" Cancellation"))
           {
               paymentDisposition = DictionaryEntry.Value.;
           }
        }

        return paymentDisposition;

    }

任何想法为什么它会抛出错误。

0 个答案:

没有答案