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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top