Hi Guest

MobileUser

1 HomePage 1 Jobs 1 WalkIn 1Articles  

Cat Exam

 :) Latest Topic
AJAX
VB.NET
SQL Query
UDDI
CLASS
JavaScript Questions
SharePoint Interview
SilverLight
WCF
general knowledge
 ASP.NET
 :) Hot Jobs
 
 :) Latest Articles


  

 


How to do Array Slicing Using LINQ?
Question Posted on 12 Mar 2022

Home >> DotNet >> LINQ >> How to do Array Slicing Using LINQ?




How to do Array Slicing Using LINQ?
To understand this we will take an array of 10 elements and out of which we need to return five of them, with the intention to return the rest of them on demand. And it is known as pagination and it is achieved by using two mainly methods of LINQ that are Skip() and Take(). So import LINQ and use two of these methods as in below given example:-


var objElements=new string[] {"E1","E2","E3","E4","E5","E6","E7","E8","E9","E10"};
var objSliced=objElements.Skip(0).Take(5);
foreach (var obj in objSliced)
Console.WriteLine(obj);



In above code we pass number of element we want to skip is pass to Skip() method. And this will turns out to be starting index as we put 0 with Skip methods. And in second method is Take() here we pass the number of elements which we want to include in Take() method. And this operation returns a new IEnumerable that we can enumerate.
0
0



 
 Input Your Comments Or suggestions(If Any)
 Name
 Email(optional)
 Comments


Other Important Questions
Important aspects of Query Operators in LINQ?
How to sort array using LINQ
Get multiple of 3 from given array with LINQ
Single() vs SingleOrDefault() vs First() vs FirstOrDefault() in LINQ Query
What are the different LINQ provide






 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |