- static public string table2Json(DataSet ds, int table_no)
- {
- try
- {
-
- int rcnt = ds.Tables[table_no].Rows.Count;
- int ccnt = ds.Tables[table_no].Columns.Count;
-
-
- object[][] tb = new object[rcnt][];
-
- int r = 0;
- foreach (DataRow dr in ds.Tables[table_no].Rows)
- {
- tb[r] = new object[ccnt];
- for (int col = 0; col < ccnt; col++)
- {
- tb[r][col] = dr[col];
-
- if ((tb[r][col]).Equals(System.DBNull.Value))
- tb[r][col] = "";
- }
- r++;
- }
-
- var table= JsonConvert.SerializeObject(tb);
- return table;
- }
I have some code for convert table to json string i want to remove for loo from these code how does it is possible