How to get the Invert indexs from array1 (if the element is absent in array2) 'linq'

Mansour_Dalir 2,036 Reputation points
2023-06-17T04:27:01.4733333+00:00

hi

And How to delete a post?

     Dim array1()as string = {"1", "2", "3", "4", "5", "6", "7", "8"}
     Dim array2()as string = {"1", "2", "3", "5", "6", "8"}
     'Result  output as integer (0,1,2,4,5,7) Invert
Developer technologies | VB
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2023-06-19T02:23:10.9533333+00:00

    Hi @Mansour_Dalir ,

    You can refer to the following code.

    Dim resultIndexes As Integer() = array1.
        Select(Function(element, index) New With {.Element = element, .Index = index}).
        Where(Function(item) array2.Contains(item.Element)).
        Select(Function(item) item.Index).
        ToArray()
    

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.