Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# find all indexes

public static int[] FindAllIndexOf<T>(this T[] array, Predicate<T> filter)
        {
  			// Note: If select does not find a match returns index as "-1"
            int[] indexes = array.Select((elementInArray, index) => filter(elementInArray) ? index : -1)
                                 .Where(index => index != -1).ToArray();

            return indexes;
        }
Comment

c# list find index

// given list1 {3, 4, 6, 5, 7, 8}
list1.FindIndex(x => x==5);  // should return 3, as list1[3] == 5;
Comment

PREVIOUS NEXT
Code Example
::  
::  
Csharp ::  
::  
::  
Csharp ::  
::  
:: add row count devepxress report 
::  
::  
Csharp ::  
::  
Csharp ::  
::  
::  
::  
::  
::  
::  
::  
::  
Csharp ::  
::  
::  
::  
::  
::  
::  
:: wpf stackpanel 
Csharp ::  
ADD CONTENT
Topic
Content
Source link
Name
5+2 =