C# Iterate through Class properties
You could possibly use Reflection to do this. As far as I understand it, you could enumerate the properties of your class and set the values. You would have to try this out and make sure you understand the order of the properties though. Refer to this MSDN Documentation for more information on this approach. For a hint, you could possibly do something like:
1 2 3 4 5 6 7 |
Record record = new Record(); PropertyInfo[] properties = typeof(Record).GetProperties(); foreach (PropertyInfo property in properties) { property.SetValue(record, value); } |
Where value is the value you’re wanting to write in (so from your resultItems array).