vendredi 14 septembre 2018

how to increment a variable if it is the first row of data table

i have a data table having several rows.I want to increment a variable say i, only if it is the first row of the data table. Hoe can i do that?

 foreach (DataRow row in dt.Rows)
     {  
 address = (row["address"].ToString());
 Counter += 1;
int count = Convert.ToInt16(emailFromDt.Rows[i]["limit"]);

         //for the first row
             if (Counter == count)
            {
              i += 1;
            }
         //also if it is the last row  
             exit;

Aucun commentaire:

Enregistrer un commentaire