开发者

How to create a key/value pair like VeiwBag in asp.net mvc?

开发者 https://www.devze.com 2023-03-17 17:04 出处:网络
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:)

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

0

精彩评论

暂无评论...
验证码 换一张
取 消