Written By:- Isha Malhotra
Take is used to take the value from the beginning according to your count. It will work like top command which we use in SQL.
int[] marks = new int[] { 23, 45, 78, 90, 56, 89, 10, 32 };
//it will take first five value from the array
var data_take = (from res_take in marks
select res_take).Take(5);
foreach (int res_data_take in data_take)
{
Response.Write(res_data_take + " ");
}
TakeWhile select the data till the condition will be true.
int[] marks = new int[] { 23, 45, 78, 90, 56, 89, 10, 32 };
//it will take first five value from the array
var data_take = (from res_take in marks
select res_take).TakeWhile(x => x % 2 != 0);
Response.Write("use of take while <br/>");
foreach (int res_data_take in data_take)
{
Response.Write(res_data_take + " ");
}
The output of this code is as follows:-
Figure 1
For any query you can send mail at info@techaltum.com
Thanks