The First
method is one of the many extension methods provided by Linq.
Given you are using C++/CLI, you might want to check this question on how to use Linq with C++/CLI.
.NET: Get HashSet element using First() or Take()
-
11-12-2021 - |
Question
Ok, I am stuck with a .NET beginners problem. I am using C++/CLI so it is a little hard to find code examples. WWW gave me a lot of stuff to read - but no solution.
I am using .NETs HashSet. I tried to take/get a random element of the set. It must not actually be a random element, it also may be the first or last. Simply any one element.
There is no method providing this. However the documentation http://msdn.microsoft.com/en-us/library/bb359438.aspx lists some so called "Extension methods". One of them that would solve my problem is First()
. Alas I have no idea how to use it. I tried myHashSet->First()
and some other rubbish but the compiler tells me it doesn't know that method.
So, please tell me how I can call that First() "Extension Method" on a HashSet using C++/CLI.
Solution