I have two files. First containing ca. 20 lines.

```
202    0021.ccc1.2e3b    DYNAMIC     Gi1/0/31
202    0023.246b.dd96    DYNAMIC     Gi1/0/16
202    0023.246e.2e41    DYNAMIC     Gi2/0/16

```

the other(I blacked out the IPs, estimate 1000 lines):

```
Internet  172.ZZ.XX.01           1   0021.ccc1.2e3b  ARPA   VlanXXX
Internet  172.ZZ.XX.02           0   0023.246e.2e41 ARPA   VlanXXX
Internet  172.ZZ.XX.03           3   0023.246b.dd96  ARPA   VlanXXX

```

Now I need to merge those two files that I get the port, the MAC and the IP:

```
172.ZZ.XX.03 0023.246b.dd96 Gi2/0/16
172.ZZ.XX.02 0023.246e.2e41 Gi1/0/16
172.ZZ.XX.01 0021.ccc1.2e3b Gi1/0/31

```

So basically I need to go through the first file and find the equivalent by MAC in the second file. Then print/output these three values.

I tried it with Dictionaries and Hashtables, but its complicated and I'm kind of stuck. Is there an easy way to accomplish this task?

Additionaly complicating is the fact that in the 1st file, one interface/port may occur more than once and in the second, there can be more than one time the same MAC.

edit: request of my attempt

I put every line in a List (first file is TargetSwitch, 2nd CoreSwitch), then calling InitHashtable to put the data in two hashtables. After that I find the Matches in a funky way by iterating through the hashtable. The Ports meight also not be correct because it takes the first which correspondents to the mac-Adress

```
private void InitHashtable()
    {
        foreach (string line in ListEntryTargetSwitch)
        {
            htTargetSwitch.Add(line.Split(delim, StringSplitOptions.RemoveEmptyEntries)[1], line.Split(delim, StringSplitOptions.RemoveEmptyEntries)[3]);
        }

        foreach (string line in ListEntryCoreSwitch)
        {
            if (line.Split(delim, StringSplitOptions.RemoveEmptyEntries)[3] != "Incomplete")
            {
                htCoreSwitch.Add(line.Split(delim, StringSplitOptions.RemoveEmptyEntries)[1], line.Split(delim, StringSplitOptions.RemoveEmptyEntries)[3]);
            }

        }
    }

    private void FindMatches()
    {
        StreamWriter sw = new StreamWriter(_txtResult3, false);

        foreach (string mac in htCoreSwitch.Values)
        {
            if (htTargetSwitch[mac] != null)
            {
                sw.WriteLine(mac + " " + htTargetSwitch[mac] + " " + htCoreSwitch.Keys.OfType<string>().FirstOrDefault(s => htCoreSwitch[s] == mac));
            }

        }
        sw.Close();
    }

```