Not able to compile below code

new List(Of String) from {“Germany”,“Spain”,“Japan”,“Brazil”,“India”,“China”}

List1.GetRange(List1.Count-5,List1.Count-1) // Compiles
List1.GetRange(List1.Count-3,List1.Count-1) // Does Not Compile

Error:
Assign: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.

Hi @morandekunal
Welcome to UiPath Community

list1.count is 6
List1.GetRange(List1.Count-5,List1.Count-1) this has index 1,count is 5 elements which means subset starts at 1 and takes 5 elements which is valid as total numbers of elements are 6

while

List1.GetRange(List1.Count-3,List1.Count-1) this has index 3 and count of elements that the subset must have is 5 elements and this is not possible as total elements in List1 are only 6, to get second statement correct you need to have List1.Count as 8 i.e total 8 elements in the list

if this is solves mark this as solution as this will help others aslo
hope this is helpful

i am getting same error in write cell activity
it has 2000 records and corresponding to 733-750 records i need to write but when it goes to 734 it shows the same error
Write Cell: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.