How to delete/remove from starting to a specific item of an array

Hi Team,

I have an array[string] with values {a,b,c,d,e,f,g,h,i j}

I need to remove the items starting from d : {a,b,c,d}

Output shoule be : {f,g,h,i,j}

Appreciate your help!

Hi @suresh.ghadai

You can try array except function

Enumerable.Except Method (System.Linq) | Microsoft Learn

Like this ouputarray = numbers1.Except(numbers2)

Thanks
John

image

@johnfelix . Thank you!

Hello @suresh.ghadai ,

You can use the below method.

list.GetRange(list.IndexOf("d"),list.Count-1).ToList

Thanks,
Sanjit

@Sanjit_Pal,

My value is in a string array i.e InputArray

The above method is not working for Array

Please get same method in Array.

you can convert that array to list using arrVar.ToList and use the above method and at the end you can again convert it to array using arrVar.ToArray

1 Like

@Sanjit_Pal

Please check once. I am getting an error.

Note: SrArray is my Array of strings

@Sanjit_Pal

Sorry SrArrayList is my Array name

the method name is IndexOf not index

@Sanjit_Pal

Hi Sanjit,

I have an excel sheet with 6 sheets. By applying the below method it is removing only one sheet. If am providing the out_Config(“WorkingSheet”).ToString =Sheet3
I should be getting the value for Sheet4, Shee5 and Sheet6
out_Config(“WorkingSheet”).ToString= Sheet4,
I should be getting the value for Sheet5 and Sheet6

Excel sheet has : Sheet1, Sheet2, Sheet3, Sheet4, Sheet5 and Sheet6

arraySheet.ToList.GetRange(arraySheet.ToList.IndexOf(out_Config(“WorkingSheet”).ToString),arraySheet.ToList.Count-1).ToArray

Please help on this!

have a look here
image

workSheetsList.Skip(workSheetsList.IndexOf(“Sheet3”)).Take((workSheetsList.Count-1)-workSheetsList.IndexOf(“Sheet3”)).ToArray

@Sanjit_Pal

image

image

Getting the above error. Please see
the method , anything i have missed …

Your help will be appreceiated!

If you have Queries, Don’t close the topic and ask Question.

Before mark as solution You should check the expected output after that you should mark a solution.

If you your are discussing about the new query create a new topic @suresh.ghadai

kindly check are you having the values in out_Config or it’s null?

No Sanjit . i am getting value for Out_Config

@Gokul001
Sorry by mistakenly it was clicked on solution. It was same query.

Thanks!

No worries. Kindly click it back again and continue to discuss @suresh.ghadai

can you please share your xaml with sample data I will correct and share it with you.

Hi @suresh.ghadai ,

If you need the Sheets that are present after the Sheet that needs to be searched/indexed, then you could try the below :

wbSheets.Skip(wbSheets.IndexOf("Sheet3")+1)

image