DEV Community

C#: functional approaches explained solving one specific problem

Taqmuraz on February 04, 2024

Today I would like to tell you about functional approaches. Why they are good, and why they are simple. We need to write some code Let ...
Collapse
 
trueromanus profile image
Roman Vladimirov • Edited

What about items.GroupBy(a => a.First()).Select(a => a.First()).ToList() ?

Collapse
 
taqmuraz profile image
Taqmuraz

Mathematically this solution is 100% correct :)

Collapse
 
bigboybamo profile image
Olabamiji Oyetubo

Nice!
FYI next time, if you’re writing a codeblock for C# code you can use ‘’’cs in the markdown and it will generate nice colorful C# code

Collapse
 
taqmuraz profile image
Taqmuraz

Thank you! :)

Collapse
 
fst2000 profile image
Sergey

so cool!

Collapse
 
evgenijshelukhin profile image
evgenijShelukhin

Good, thanks.
I think dotnet should add the ability to use a predicate instead of IEqualityComparer (and IComparer) in the default api.

Collapse
 
taqmuraz profile image
Taqmuraz

Yes!
Or they should add a possibility to implement an interface by delegate.