Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在运行时使用反射在动态对象上创建属性?
属性的名称只会在运行时知道,而不是编译时知道。
dynamic data = new ExpandoObject(); var dataDictionary = (IDictionary<string, object>)data; //add property dataDictionary.Add("Name", "AwkwardCoder"); //access var name = data.Name;