Generic.List

  • Thread starter Thread starter shapper
  • Start date Start date
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
 
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
 
Back
Top