【问题标题】:'System.Collections.Generic.Mscorlib_DictionaryDebugView<string,string>' is inaccessible due to its protection level'System.Collections.Generic.Mscorlib_DictionaryDebugView<string,string>' 由于其保护级别而无法访问
【发布时间】:2017-09-22 01:18:50
【问题描述】:

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

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

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

CS0122:'System.Collections.Generic.Mscorlib_DictionaryDebugView&lt;string,string&gt;' is inaccessible due to its protection level

Here you can check the image for same.

谁能告诉我如何获取记录?

【问题讨论】:

  • 我发现用internal sealed class Mscorlib_DictionaryDebugView&lt;K, V&gt; 声明的类,那么listCustomerType 是Sharepoint 相关列表吗?

标签: c# asp.net json xml


【解决方案1】:

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

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

【讨论】:

  • 感谢您的快速回复。我明白了,但你能告诉我如何找到解决方案吗?我正在获取变量中的详细信息,但我如何从中获取值和键。我试图在 List 中接收它,但后来我只得到了名称而不是值。
【解决方案2】:

这很简单。我不知道为什么我喜欢从 Mscorlib_DictionaryDebugView 获取数据。好笑……不是吗?

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

Dictionary&lt;string, string&gt; 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);
        }

谢谢大家的帮助。

【讨论】:

  • 因此,如果您的问题确实详细说明了引发错误的代码行,我们可能会更快地帮助您。
猜你喜欢
  • 1970-01-01
  • 2015-09-26
  • 2011-09-01
  • 1970-01-01
  • 2011-04-02
  • 2011-02-07
  • 2012-01-25
相关资源
最近更新 更多