【问题标题】:Trying to define WebMethod with dictionary as parameters尝试使用字典作为参数定义 WebMethod
【发布时间】:2017-06-14 18:29:41
【问题描述】:

我正在使用 C#。

我正在尝试在我的 .asmx 文件中创建一个 Web 方法,如下所示:

[WebMethod]
public string MyWebMethod(Dictionary<string, string> parameters)
{
   //...
}

我得到了以下异常:

The type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is not supported because it implements IDictionary.

我该如何解决?

谢谢。

【问题讨论】:

    标签: c# asp.net web-services asmx


    【解决方案1】:

    你不能直接使用Dictionary,但你可以使用list作为参数

    此链接可以帮助您将List 转换为Dictionary并继续您的流程

    C# Convert List to Dictionary

    【讨论】:

      猜你喜欢
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-18
      • 2021-01-19
      • 2011-09-03
      • 1970-01-01
      • 2012-02-15
      相关资源
      最近更新 更多