c# - Can't execute Foreach for GetEnumerator -


when declare foreach compiler show me following error:

foreach statement cannot operate on variables of type 'system.data.datatable' because 'system.data.datatable' not contain public definition 'getenumerator

this code:

leaguetable_link = item.links.leaguetable.href.tostring(); object leaguetable_object = load_league_table(leaguetable_link);  foreach (var classifica in leaguetable_object) {  } 

and class created online tool json2c#:

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks;  namespace test { class leaguetable {     public string[] _links = new string[50];      public int[] position = new int[50];     public string[] teamname = new string[50];     public int[] playedgames = new int[50];     public int[] points = new int[50];     public int[] goals = new int[50];     public int[] goalsagainst = new int[50];     public int[] goaldifference = new int[50];     public struct league_struct     {         public string _links;         public int position;         public string teamname;         public int playedgames;         public int points;         public int goals;         public int goalsagainst;         public int goaldifference;     }     public league_struct[] league_struct = new league_struct[50];     public class links     {         public string self { get; set; }         public string soccerseason { get; set; }     }     public class team     {         public string href { get; set; }     }     public class links2     {         public team team { get; set; }     }     public class standing     {         public links2 _links { get; set; }         public int position { get; set; }         public string teamname { get; set; }         public int playedgames { get; set; }         public int points { get; set; }         public int goals { get; set; }         public int goalsagainst { get; set; }         public int goaldifference { get; set; }     }     public class rootobject     {         public  links _links { get; set; }         public string leaguecaption { get; set; }         public int matchday { get; set; }         public list<standing> standing { get; set; }     } } 

}

the leaguetable_object contain this:

var obj = jsonconvert.deserializeobject<leaguetable.rootobject>(responsetext); 

how can fix this? see online different solution don't understood. should implement getenumerator class in json class?

the type of leaguetable_object object seems 'system.data.datatable' not enumerable type can't loop on object. can loop on rows in datatable :

leaguetable_link = item.links.leaguetable.href.tostring(); datatable leaguetable_object = load_league_table(leaguetable_link);  foreach (var classifica in leaguetable_object.rows) {  } 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -