Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# list slice

// list[2:4]
var result1 = myList.Skip(2).Take(2);
// list[1:]
var result2 = myList.Skip(1);
// list[:3]
var result3 = myList.Take(3);
// list[:3] + list[4:]
var result4 = myList.Take(3).Concat(myList.Skip(4));
Comment

c# list slice

// only available in .NET Core 3.0   :/

var result1 = myList[2..5]; // end (5) is exclusive
var result2 = myList[1..^0]; // from index 1 to the end 
var result3 = myList[0..3]; // end (3) exclusive
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity how to move an object 
Csharp :: get folder path winforms 
Csharp :: how to add to a list c# 
Csharp :: c# convert string to url encoding 
Csharp :: unity stop animation from playing at start 
Csharp :: ienumerable foreach 
Csharp :: how to see image from website in wpf 
Csharp :: order by length descending C# 
Csharp :: unity round float to nearest 10 
Csharp :: unity get perlin noise 3d 
Csharp :: how to pass string value to enum in c# 
Csharp :: c# Get type with namespace 
Csharp :: unity call function on animation finish 
Csharp :: check if internet is connected with c# winforms 
Csharp :: {"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."} 
Csharp :: CS0101 
Csharp :: unity pause game c# 
Csharp :: instantiate object in circle 
Csharp :: c# nullable string 
Csharp :: get current time c# 
Csharp :: multithreading in c# 
Csharp :: convert string to jtoken c# 
Csharp :: c# delegate 
Csharp :: c# foreach object in array json 
Csharp :: c# multiple strings are empty 
Csharp :: get percentage c# 
Csharp :: The foreach Loop c# 
Csharp :: c# excel close workbook 
Csharp :: vb.net add row to datagridview programmatically 
Csharp :: make variables in c# 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =