for and foreach loop in c#

for and foreach loop in c#

for

                    decimal perk_perc = 0;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        perk_perc += Convert.ToDecimal(dt.Rows[i]["PercentageTaken"]);
                    }
for (int i = 1; i <= 10; i++)  
{  
   i = i + i;  
}

foreach

int j = 0;  
int[] Arr = new int[] { 0, 1, 2, 3,4, 5, 8, 9,10 };  
foreach (int i in Arr )  
{  
   j = j + i ;  
} 

 

2020-02-19