How to create a key/value pair like VeiwBag in asp.net mvc?
hi guys i was wondering i开发者_如何学运维f there is any way to use dynamic data type in c# 4.0 as something like viewbag in asp.net mvc (something like the following:)
myProprty.SomeValue=SomeObject;
// which myProperty is the key and SomeVale is value of pair
//and the to retrieve the value:
object o = myProperty.SomeValue;
An ExpandoObject should do exactly what you need: http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject.aspx
精彩评论