【发布时间】:2014-03-26 14:44:46
【问题描述】:
是否有可能在 C# 中使用字符串值来创建对象属性? 像这样:
object obj;
obj.makePropperty("username","user1");
obj.makePropperty("firstName","jnah");
obj.makePropperty("year",2014);
String getValue = obj.username;
【问题讨论】:
-
你不能使用
Dictionary吗? -
你有什么想法吗!
-
IDictionary
dict = new Dictionary { { "Foo", "Bar" } };动态 dobj = dict.toexpando();我找不到 toexpando 定义! -
据我所知框架中没有 ToExpando 方法。这篇文章谈论创建你自己的。 stackoverflow.com/questions/6667273/…
标签: c# asp.net-mvc string asp.net-mvc-4 object