| Syntax for Foreach loop to handle dataset with string and string builder
Below is the synta to handle foreach loop
(1)Use of string with foreach
string EmpName = string.Empty;
foreach(row in Dataset)
{
EmpName += row.Name;
}
(2)Use of StringBuilder with foreach
Stringbuilder sbval = new StringBuilder();
foreach(row in Dataset)
{
sbval.Append(row.Name);
}
string EmpName = sb.ToString(); | | |