Count of Spesific Element in Array and Splitting Array

Hello. I am not good at dealing with arrays. I have couple arrays like this:

{SSB45, GFD, 4, 34 /GAL, 21/GAL, 45/GAL, RE, 12}

Element amount which contains “/GAL” is changing. I want to count number of elements which contains “/GAL”. Also, how can I split the elements which contain “/GAL” to new array?


Hope the following helps you.

arr = {"SSB45", "GFD", "4, 34 /GAL", "21/GAL", "45/GAL", "RE, 12"}

count = arr.Count(Function(x) x.EndsWith("/GAL"))

newarray = arr.Where(Function(x) x.EndsWith("/GAL")).ToArray

Sequence1.xaml (5.8 KB)


Thank you for your help. It is working. What does Function(x) do in this code? I have never used it before.


Function() is lambda expression in Visual Basic.
In this case, it iterates items of array, then do count(Count method) or filter(Where method).

We can get detailed information to serach by “LINQ” “VisualBasic” “Lambda expression” etc.



This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.