VB :
Dim example As Integer() = {1, 2, 3, 2, 4, 52, 6, 7, 2, 8, 2, 9, 2}
' Use LINQ to find all indices where value is 2
Dim indices = example.Select(Function(value, index) New With {Key .Index = index, Key .Value = value}) _
.Where(Function(x) x.Value = 2) _
.Select(Function(x) x.Index) _
.ToList()
C# :
int[] example = { 1, 2, 3, 2, 4, 52, 6, 7, 2, 8, 2, 9, 2 };
// Use LINQ to find all indices where value is 2
var indices = example.Select((value, index) => new { Index = index, Value = value })
.Where(x => x.Value == 2)
.Select(x => x.Index)
.ToList();