CSharpBeginner
CSharpBeginner

Reputation: 611

Trying to define WebMethod with dictionary as parameters

I'm Using C#.

I'm trying to create a web method in my .asmx file as follow:

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

And I got the following exception:

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.

How can i fix it?

Thanks.

Upvotes: 1

Views: 798

Answers (1)

shady youssery
shady youssery

Reputation: 440

you can't use Dictionary direct but you can use list as parameters

and this link can help you to convert List to Dictionaryand continue your flow

C# Convert List to Dictionary

Upvotes: 1

Related Questions