c# - How to check for object of particular type in a HashSet in windows 8? -
i have hashset
of generic type usercontrol
, can have various usercontrol (login, settings). want check whether set contains object of particular type (say login). if want element.
i know quite easy loop, there better way?
unfortunately, cannot without loop, because need try elements of collection check types. in fact, not matter have hash set: work same list, or other enumerable. however, linq lets hide loop, this:
var item = hashset.oftype<desiredtype>().firstordefault();