I have two custom classes in VB.NET and I am using them as lists of classes to contain multiple elements with these properties
One is called materialsDefinition which contains the following:
Public Property id As Integer
Public Property name As String
Public Sub New(ByVal identification As Integer, ByVal material As String)
id = identification
name = material
End Sub
A list of this class will be used as a materials dictionary, where you will have an ID, for example "1", and a material name, "A_286", or for example "2" and "17-4PH"
{"1", "A_286"}, {"2", "17-4PH"}
Another class is componentInfo, with a similar structure to the other class:
Public Property componentName As String
Public Property materialID As Integer
Public Sub New(ByVal component As String, ByVal identification As Integer)
materialID = identification
componentName = component
End Sub
Where you will have a name of the component in an assembly, for example "Pin" and its material ID "1", which corresponds to the material in the other class, A_286, and "Nut" and its material ID "2" corresponding to 17-4PH
{"Pin", "1"}, {"Nut", "2"}
I want to create a function that looks up and matches the material ID that exists in both classes, and saves the material name in a new array that will contain the following information:
{"Pin", "A_286"}, {"Nut", "17-4PH"}
I'm not sure how though, I thought the most rudimentary solution first which will be looking one by one in a If loop inside a for loop but it would be better to use a "Find" function.
The issue I have is I don't know how to use a find function, or findIndex, or Exists in VB.NET and in a list of a custom class.
Also the size of both lists can be different and the materials list be bigger, or shorter than the component list.
I would appreciate any input given. Thanks.