Generic.List

S

shapper

Hello,

I have an Enum and a Generic.List(Of Enum)

1 Public Enum Mode
2 Count
3 Day
4 Month
5 End Enum

Can my Generic List have duplicated values?

For example:

1 Dim gl As Generic.List(Of Mode)
2 gl.Add(Mode.Count)
3 gl.Add(Mode.Count)

I suppose Mode.Count will be added only once, right?

And how can I find if the Mode.Count has been added to my Generic
List?

Thanks,

Miguel
 
G

Guest

Miguel,

There is no restriction on what you can put into generic list.

Consider enabling <Flags> attribute on your enumeration:

<System.Flags()> _
Public Enum Mode
Count = 1
Day = 2
Month = 4
End Enum

And then you could use your variables of type Mode could be any combinations
of the above items, with no duplicates
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Generic List. Remove duplicate 2
CheckBox 1
Generic List to Array 2
Generic.List. Is this possible? 2
Average 1
String 2
Generic List 3
Is Nothing problem 16

Top