
Originally Posted by
ForumAccount
John just missed the OfType function:
vb.net Code:
[Enum].GetValues(GetType(IO.Ports.StopBits)).OfType(Of IO.Ports.StopBits)().Skip(1)
(Arrays only implement IEnumerable and not the generic version, thus you don't get all the fancy stuff until it is cast.)
Actually, OfType is intended to be used as a filter to extract items of one type from a list containing multiple types, so it would actually be more appropriate to call Cast:
vb.net Code:
[Enum].GetValues(GetType(IO.Ports.StopBits)).Cast(Of IO.Ports.StopBits)().Skip(1)
Also, we know that None is the first value, so Skip(1) works but, if you want to be more explicit, you might exclude None specifically, so its actual position doesn't matter:[Enum].GetValues(GetType(IO.Ports.StopBits)).Cast(Of IO.Ports.StopBits)().Where(Function(sb) sb <> IO.Ports.StopBits.None)[/HIGHLIGHT]