In TagBuilder and other classes I can write something like:
var tr = new TagBuilder("HeaderStyle"){InnerHtml = html, [IDictionary Attributes]}
but I don't know how to pass the IDictionary parameter.
How can I do that on the fly? Without creating a Dictionary variable.
TagBuilder is an example, there are other classes that accept a parameter IDictionary
as well. The question is about the generic case.
Another way to create Dictionaries from Anonymous types:
new Dictionary<int, StudentName>()
{
{ 111, new StudentName {FirstName="Sachin", LastName="Karnik", ID=211}},
{ 112, new StudentName {FirstName="Dina", LastName="Salimzianova", ID=317}},
{ 113, new StudentName {FirstName="Andy", LastName="Ruth", ID=198}}
};
http://msdn.microsoft.com/en-us/library/bb531208.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With