0

I wrote a function for comparing two Hashsets and returning differences but I would like that the returned array contains the names of sent Hashsets instead of "1" and "2".

Is it possible? (My research said NO!) Is there another way to to do something similar?

Here's my code:

Public Function myDiff(ByVal H1 As HashSet(Of String), ByVal H2 As HashSet(Of String))
    Dim In1No2 As New list(Of String)
    Dim In2No1 As New list(Of String)
    In1No2.add("In 1 and not in 2")
    In2No1.add("In 2 and not in 1")
    For Each mVal In H1
        If Not H2.Contains(mVal) Then In1No2.Add(mVal)
    Next
    For Each mVal In H2
        If Not H1.Contains(mVal) Then In2No1.Add(mVal)
    Next

    Return {In1No2.toarray, In2No1.toarray}
End function
Fjodr
  • 919
  • 13
  • 32
genespos
  • 3,211
  • 6
  • 38
  • 70
  • It's possible. If a c# example will help, then look at [this post.](http://stackoverflow.com/questions/9801624/get-name-of-a-variable-or-parameter) – Zohar Peled May 28 '15 at 11:17
  • There are a few ways to do that: to returm a List Of Strings, first try for me, is to declare/new that list of strings in init or Load funtion , and in myDiff just to clean and repopulate each list.. – CristiC777 May 28 '15 at 12:10
  • @ZoharPeled Thanks, my previous research was wrong. But, searching on "getname", it seemed to me to understand that it works only on "enum" type and I wasn't able to work with it: before writing the function, I've tryed to use "except" without success. Maybe I need to learn more before trying to do This. – genespos May 28 '15 at 14:07

0 Answers0