I really like the anonymous type syntax. e.g.
new {a = 1, b = 2, c = 25.2}
It'd be neat if there was a version like this for Expando or Dictionary. Is there a way?
You can do this
Dictionary<string, object> dict =
new Dictionary<string, object> { { "a", "foo" }, { "b", 1 } };
Also note that you can do
var O = new { A = "foo", B = 12 };
If you could settle for Dictionary, you could try:
var dict =
new Dictionary<string, double> { { "a", 1 }, { "b", 2 }, { "c", 25.2 } };
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