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:

  1. don't call property searchresults because that's class's name. call searchresults .
  2. 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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -