how to convert an instance of an anonymous type to a NameValueCollection
Posted
by Frank Schwieterman
on Stack Overflow
See other posts from Stack Overflow
or by Frank Schwieterman
Published on 2010-05-15T00:18:45Z
Indexed on
2010/05/15
0:24 UTC
Read the original article
Hit count: 636
c#
|anonymous-types
Suppose I have an anonymous class instance
var foo = new { A = 1, B = 2};
Is there a quick way to generate a NameValueCollection? I would like to achieve the same result as the code below, without knowing the anonymous type's properties in advance.
NameValueCollection formFields = new NameValueCollection();
formFields["A"] = 1;
formFields["B"] = 2;
© Stack Overflow or respective owner