c# - Generics in a Dictionary as an Input in a method -


i trying create method accepts dictionary input.

however, when try add following:

 public void writetojsonfile(dictionary<string, t> diclist)  {  ... stuff  } 

it state t missing assembly or reference. now, have worked around adding

<t> 

to class name generic class. using dictionary class want create method accept dictionary key string value can of object?

i have worked around adding <t> class name generic class.

you should not this, unless have specific need class generic.

all want create method accept dictionary key string value can of object?

all need dictionary<string,object> then: way, single dictionary have objects of different types, keyed string. better, use idictionary<string,object> let class users pass other implementations of idictionary<k,v> interface.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -