Checking System.Array's item's naming in

Hakan used Ask the Experts™
Hi, I'm using below COM-interface function to get a list of used parameters in 3rd part program. Function output type is System.Array and item's like below;


Open in new window

Sample Output of model.getParameterList() as System.Array:

As in example F_x, F_y, F_z, M_x, M_y, M_z is related to each other so i'd like to check (e.g.) item starting with "$X_FR_TABUl" has F_x, F_y, F_z, M_x, M_y, M_z items. If all of them is existing it will return True else it will return False for each item.


Because as you can see $X_FR_FADAl_M_y is it missing.

Is there anyway to quick check these naming with best approach (maybe with LINQ) in ?

Any help would be grateful. Thanks.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
hmm, too few information..

E.g. why working with an array and not an mapped object? Cause a mapped object could provide this information automatically after instantiation.

For optimal solutions:
How is the naming pattern defined? Is it a positional, fixed "pattern" or a real regex-style one? Do you want to check for x-y or [F|M] & x-z?

A possible approach with LINQ:

Module Module1
    Sub Main(args As String())
        Dim result = ModelGetParameterList() _
             .OfType(Of String) _
             .ToList() _
             .GroupBy(Of String)(Function(item) (item.Substring(1, item.Length - 3)))

        For Each r In result
            Console.WriteLine(r.Key + " " + r.Count.ToString())

    End Sub

    Function ModelGetParameterList() As Array
        ModelGetParameterList = {"$X_FR_TABUl_F_x", "$X_FR_TABUl_F_y", "$X_FR_TABUl_F_z", "$X_FR_FABUl_M_x", "$X_FR_FABUl_M_y", "$X_FR_FABUl_M_z", "$X_FR_FADAl_F_x", "$X_FR_FADAl_F_y", "$X_FR_FADAl_F_z", "$X_FR_FADAl_M_x", "$X_FR_FADAl_M_a", "$X_FR_FADAl_M_z"}
    End Function
End Module

Open in new window


Thanks ste5an that's what i am looking for, but could you please show me how can , it looks F's as a one group and M's are one group. I'm looking for the F_x, F_y_ F_z, M_x, M_y,_ M_z as one group so i expected;

            Console.WriteLine(r.Key + " " + r.Count.ToString())
r.count.tostring //output will be 6.
ste5anSenior Developer

Just change the value in the group by function from 3 to 1.


Thanks for the information how can i check single value with your code like $X_FR_TABUl_F_x ?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial