hi everyone, i want to ask, if infos variable inside have a many data, how can i get just 5-6 data ?
foreach (var info in infos)
{
htmlTh = new TableHeaderCell();
htmlTh.Text = info.Name;
htmlTr.Cells.Add(htmlTh);
}

Raja TPosted Nov 12, 2015, 1:54 AM
Banketeshvar NarayanPosted Nov 12, 2015, 2:12 AM
You are most Welcome..
But just right now I have seen that you have written that you want the result using LINQ.
you can achieve it by below query
var list = (from t in infos
select t
).Take(5);
Please accept as answer if it helps you.
Raja TPosted Nov 12, 2015, 2:04 AM
Ekrem TapanPosted Nov 12, 2015, 2:02 AM
Banketeshvar NarayanPosted Nov 12, 2015, 1:43 AM
You can decide that which data you want to iterate using break and continue.
You can use something like
foreach (var info in infos)
{
if (info != yourequireddata)
continue;
htmlTh = new TableHeaderCell();
htmlTh.Text = info.Name;
htmlTr.Cells.Add(htmlTh);
}
or if you need only 5 data you can use break keyword.