create the dynamic object list in c# (Expando object)
create the dynamic object list in c# (Expando object)
In this post am going to explain about creating dynamic object list using Expando Object
See the bellow implementation
var DynamicObjList = new List<dynamic>();
dynamic obj = new ExpandoObject();
obj.someDynamicFiledname= "some value";
If you want to add field name also dynamically use bellow
var objDictionary = obj as IDictionary<string, object>;
objDictionary .Add("your filedname","value");
objDictionary =objDictionary .ToDictionary(x => x.Key, x => x.Value);
DynamicObjList.Add(objDictionary );
hope this will helps you
In this post am going to explain about creating dynamic object list using Expando Object
See the bellow implementation
var DynamicObjList = new List<dynamic>();
dynamic obj = new ExpandoObject();
obj.someDynamicFiledname= "some value";
If you want to add field name also dynamically use bellow
var objDictionary = obj as IDictionary<string, object>;
objDictionary .Add("your filedname","value");
objDictionary =objDictionary .ToDictionary(x => x.Key, x => x.Value);
DynamicObjList.Add(objDictionary );
hope this will helps you