c# - <Closed> how I can access the value of the properties in the object stored in objects -
i have class role:
class role { public role(type1 parameter1, type2 parameter2, type3 parameter3) { } }
type1, type2, type3 other classes. creating new object of type role
role role1 = new role(parameter1, parameter2, parameter3);
and adding list
list<role> listroles = new list<role>(); listroles.add(role1);
now need fill excel file items of list, how can take data objects in list.
for example, first cell must filled role1.type1.name, how can access value of properties in object
you can iterate list , needed values. in example i'm storing values in strings, can whatever needed (e.g. directly write them excel sheet):
foreach(role role in listroles) { string col1 = role.type1.name; string col2 = role.type2.name; // , on }
i assume, role
class looks this:
class role { public type1 type1 { get; set; } public type2 type2 { get; set; } public type3 type3 { get; set; } public role(type1 parameter1, type2 parameter2, type3 parameter3) { this.type1 = parameter1; this.type2 = parameter2; this.type3 = parameter3; } }
Comments
Post a Comment