I have been following this question on how to use anonymous for IDictionary
since it provides a cleaner and compact code solution.
Difference between anonymous class and IDictionary<string,object> for htmlAttributes in ASP.NET MVC?
When i was trying to test how it works, i get the following errors from my compilter:
(23:13) The best overloaded method match for 'Rextester.Program.test(System.Collections.Generic.IDictionary<string,string>)' has some invalid arguments
(23:18) Argument 1: cannot convert from 'AnonymousType#1' to 'System.Collections.Generic.IDictionary<object,string>'
Here is my code:
namespace Rextester
{
public class Program
{
public static void test(IDictionary<object,string> carl){}
public static void Main(string[] args)
{
test(new{carl="Hello", carl2="World"});
}
}
}
Can someone tell me what am i doing wrong? I even copy pasted the code from the other SO but i still keep on getting the same error.
Compiler: I am at school so I am just using an online compiler.