c# - How is this defined? -
is array of class property or property class array? , how access each row instead of each element in class in c#? thanks!
public partial class advancedsearchresult { private searchresults[] searchresultsfield; /// <remarks/> **[system.xml.serialization.xmlelementattribute("searchresults")] public searchresults[] searchresults { <-------not sure how define { return this.searchresultsfield; } set { this.searchresultsfield = value; } }** public partial class searchresults { private int didfield; private bool didfieldspecified; private int drevisionidfield; ...............etc
if understand correctly:
- don't call property
searchresults
because that's class's name. callsearchresults
. - access 'row' this:
searchresults[rownumber]
.
searchresultsfield
array, of every member searchresults
class instance. , (de facto) property. it's an array of class instances.
to access field in property use searchresults[rownumber].fieldname
(assuming public fields).
due comment - here's simple example of reflection:
public partial class form1 : form { public form1() { initializecomponent(); myclass myclass = new myclass() { = "a", j = "b" }; fieldinfo[] infos = typeof(myclass).getfields(); foreach (fieldinfo info in infos) text += info.getvalue(myclass); } } class myclass { public string i; public string j; }
and add @ top:
using system.reflection;
Comments
Post a Comment