Avatar of chadmanvb
chadmanvb
 asked on

addrange for hashset

I have a hashset and would like to add it to a combobox.

So this works
Dim strLeaderNameListString() As String
ComboBox1.Items.Clear()
        ComboBox1.Text = Nothing
        Me.ComboBox1.Items.AddRange(strLeaderNameListString)
        ComboBox1.Select()

Anything close to make this work?
Dim strLeaderNameListString As HashSet(Of String)
ComboBox1.Items.Clear()
        ComboBox1.Text = Nothing
        Me.ComboBox1.Items.AddRange(strLeaderNameListString)
        ComboBox1.Select()
.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
chadmanvb

8/22/2022 - Mon
Fernando Soto

Getting any errors? If so please post along with the inner exception.
chadmanvb

ASKER
I get an error telling me:
ComboBox1.Items.AddRange(strPKGNameList)
Error      1      Value of type 'System.Collections.Generic.HashSet(Of String)' cannot be converted to '1-dimensional array of Object'.
Fernando Soto

Try changing this line in the code :

 Me.ComboBox1.Items.AddRange(strLeaderNameListString)

To This :

 Me.ComboBox1.Items.AddRange(strLeaderNameListString.ToArray())
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
chadmanvb

ASKER
I dont see .ToArray as being an option for

Dim strLeaderNameListString As HashSet(Of String)
Fernando Soto

What version of Visual Studio are you using?
chadmanvb

ASKER
2010 pro and working with .net 4.0
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Fernando Soto

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
chadmanvb

ASKER
Works great!