&#39; System.Collections.Generic.Mscorlib_DictionaryDebugView <字符串,字符串>&#39;由于其保护级别

时间:2017-04-25 06:55:24

标签: c# asp.net json xml

我正在尝试使用JSON从XML填充ddlCustomerType。我有一种方法可以为我提供关键和价值。

var listCustomerType = GlobalBind.GetXMLFullDetails("CustomerType", GlobalConstString.COMMON_SETTING_XML);

我的问题是我能够在Quickwatch中查看数据但是当我尝试获取它时显示以下错误:

CS0122:&#39; System.Collections.Generic.Mscorlib_DictionaryDebugView<string,string>' is inaccessible due to its protection level

Here you can check the image for same.

任何机构都可以告诉我如何获取记录吗?

2 个答案:

答案 0 :(得分:1)

如果您正在尝试使用Mscorlib_DictionaryDebugView,那么您就不能。它是一个不适合公共使用的内部对象here是您可以看到其标记为internal sealed的来源。

如果您发布有关您要实现的目标的问题,我们可以引导您找到更合适的解决方案。

答案 1 :(得分:1)

非常简单。我不知道为什么我会从Mscorlib_DictionaryDebugView获取数据。有趣......不是吗?

我在字典中获取详细信息,如下所示:

Dictionary<string, string> listCustomerDetails = GlobalBind.GetXMLFullDetails("CustomerType", GlobalConstString.COMMON_SETTING_XML);

然后我使用循环来获取键和值,如下所示:

        foreach (var customer in listCustomerDetails)
        {
            ListItem ls = new ListItem();
            ls.Text = customer.Value;
            ls.Value = customer.Key;
            listItem.Add(ls);
        }

谢谢大家的帮助。