Jump to content

C# Count and delete duplicates in list

Go to solution Solved by minibois,

-snip-

Maybe this helps:

http://stackoverflow.com/questions/7832602/list-array-duplicates-with-count

 

It seems like exactly what you are looking for 

Hello, basically:
I have a string list witch contains same items.

What I have:

A
A

B
C
A
C
F


I want to create new list, witch removes duplicates and counts how many of items there are

Result I'm trying to achieve:
A 3
B 1
C 2
F 1


Any idea? For some reason my head doesn't work as it should today :|

Laptop: Acer V3-772G  CPU: i5 4200M GPU: GT 750M SSD: Crucial MX100 256GB
DesktopCPU: R7 1700x GPU: RTX 2080 SSDSamsung 860 Evo 1TB 

Link to comment
https://linustechtips.com/topic/369685-c-count-and-delete-duplicates-in-list/
Share on other sites

Link to post
Share on other sites

-snip-

Maybe this helps:

http://stackoverflow.com/questions/7832602/list-array-duplicates-with-count

 

It seems like exactly what you are looking for 

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to post
Share on other sites

This is some pseudo code

 

public acounter = 0;

public bcounter = 0;

//etc...

 

for(i = 0; i < array.count(); i++){

if(array = "A"){

acounter++;

//etc...

}

}

CPU: Intel Core i5 4690K @ 4.6Ghz CPU Cooler: Noctua NH-D15 GPU: GTX 1070 TI RAM: Crucial Ballistix Tactical 16GB (4x4) Mobo: ASUS Z97-PRO(Wi-Fi ac) PSU: Corsair RM Series RM750 Case: Fractal Design Define R4 no window

Link to post
Share on other sites

Maybe this helps:

http://stackoverflow.com/questions/7832602/list-array-duplicates-with-count

 

It seems like exactly what you are looking for 

Should work. Thanks. 

Laptop: Acer V3-772G  CPU: i5 4200M GPU: GT 750M SSD: Crucial MX100 256GB
DesktopCPU: R7 1700x GPU: RTX 2080 SSDSamsung 860 Evo 1TB 

Link to post
Share on other sites

then try again tomorrow

I'm pretty much out of time :P

Anyway, mini's link helped. Looks like LinQ is used often, I should learn it. 

Laptop: Acer V3-772G  CPU: i5 4200M GPU: GT 750M SSD: Crucial MX100 256GB
DesktopCPU: R7 1700x GPU: RTX 2080 SSDSamsung 860 Evo 1TB 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×