Click here to Skip to main content
15,888,286 members
Home / Discussions / C#
   

C#

 
AnswerRe: How do I load a block on a form at startup Pin
Gerry Schmitz23-Aug-20 6:48
mveGerry Schmitz23-Aug-20 6:48 
GeneralRe: How do I load a block on a form at startup Pin
Brian_TheLion24-Aug-20 17:03
Brian_TheLion24-Aug-20 17:03 
QuestionCreating a Windows form program using C# 8.0 Pin
Brian_TheLion22-Aug-20 20:30
Brian_TheLion22-Aug-20 20:30 
SuggestionRe: Creating a Windows form program using C# 8.0 Pin
Richard MacCutchan22-Aug-20 21:05
mveRichard MacCutchan22-Aug-20 21:05 
GeneralRe: Creating a Windows form program using C# 8.0 Pin
Brian_TheLion23-Aug-20 0:34
Brian_TheLion23-Aug-20 0:34 
GeneralRe: Creating a Windows form program using C# 8.0 Pin
Richard MacCutchan23-Aug-20 2:00
mveRichard MacCutchan23-Aug-20 2:00 
GeneralRe: Creating a Windows form program using C# 8.0 Pin
Dave Kreskowiak23-Aug-20 4:07
mveDave Kreskowiak23-Aug-20 4:07 
GeneralRe: Creating a Windows form program using C# 8.0 Pin
Brian_TheLion23-Aug-20 14:30
Brian_TheLion23-Aug-20 14:30 
GeneralRe: Creating a Windows form program using C# 8.0 Pin
Dave Kreskowiak23-Aug-20 18:38
mveDave Kreskowiak23-Aug-20 18:38 
GeneralRe: Creating a Windows form program using C# 8.0 Pin
Brian_TheLion24-Aug-20 16:55
Brian_TheLion24-Aug-20 16:55 
AnswerRe: Creating a Windows form program using C# 8.0 Pin
Mycroft Holmes23-Aug-20 12:22
professionalMycroft Holmes23-Aug-20 12:22 
GeneralRe: Creating a Windows form program using C# 8.0 Pin
Brian_TheLion24-Aug-20 16:57
Brian_TheLion24-Aug-20 16:57 
AnswerRe: Creating a Windows form program using C# 8.0 Pin
Richard Deeming23-Aug-20 23:11
mveRichard Deeming23-Aug-20 23:11 
GeneralRe: Creating a Windows form program using C# 8.0 Pin
Brian_TheLion24-Aug-20 17:01
Brian_TheLion24-Aug-20 17:01 
Question{Solved} Find and count duplicates in a list Pin
Acuena20-Aug-20 2:51
Acuena20-Aug-20 2:51 
AnswerRe: Find and count duplicates in a list Pin
OriginalGriff20-Aug-20 3:38
mveOriginalGriff20-Aug-20 3:38 
GeneralRe: Find and count duplicates in a list Pin
Acuena24-Aug-20 4:16
Acuena24-Aug-20 4:16 
GeneralRe: Find and count duplicates in a list Pin
OriginalGriff24-Aug-20 4:24
mveOriginalGriff24-Aug-20 4:24 
GeneralRe: Find and count duplicates in a list Pin
Acuena24-Aug-20 5:07
Acuena24-Aug-20 5:07 
GeneralRe: Find and count duplicates in a list Pin
OriginalGriff24-Aug-20 5:39
mveOriginalGriff24-Aug-20 5:39 
If you don't know what type something is, you can hover the mouse over it, and VS will tell you.
In this case it's a IEnumerable<IGrouping<string, string>>
Which means that it's a collection of Groups of string key / string value pairs.
Each Group in the collection has two properties you are interested in: the Key (which is the barcode number) and the Count method which tells you how many items are in each group.
So it's pretty simple to access the barcode and count:
C#
string[] lines = File.ReadAllLines(filePath);
var barcodes = lines.Select(line => {
    string[] parts = line.Split(',');
    return parts[2];
});
var x = barcodes.GroupBy(b => b);
foreach (var y in x)
    {
    Console.WriteLine($"{y.Key} : {y.Count()}");
    }
For your sample data you get:
1578456329781 : 1
1578453697235 : 3
1548795358155 : 1

"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Find and count duplicates in a list Pin
Acuena25-Aug-20 4:13
Acuena25-Aug-20 4:13 
GeneralRe: Find and count duplicates in a list Pin
OriginalGriff25-Aug-20 4:43
mveOriginalGriff25-Aug-20 4:43 
AnswerRe: Find and count duplicates in a list Pin
Afzaal Ahmad Zeeshan20-Aug-20 4:37
professionalAfzaal Ahmad Zeeshan20-Aug-20 4:37 
AnswerRe: Find and count duplicates in a list Pin
BillWoodruff22-Aug-20 21:58
professionalBillWoodruff22-Aug-20 21:58 
QuestionPowerApps and C# Pin
Member 1127440117-Aug-20 6:08
Member 1127440117-Aug-20 6:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.