Click here to Skip to main content
15,881,559 members
Home / Discussions / C#
   

C#

 
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 
Hi all!

Got a new question.
I have a barcode scanner that saves all scanned barcodes in the following format:
Date,Time,Barcode

Example:
2020-07-08,13:54:16,1578456329781
2020-07-08,14:07:13,1578453697235
2020-07-08,14:08:03,1548795358155
2020-07-08,14:11:09,1578453697235
2020-07-08,14:11:42,1578453697235


Now I add this to a ListView in Gridview mode with the following code:

List<List> items = new List<List>();
string[] lines = File.ReadAllLines(@"F:\BARCODE.txt");

foreach (string line in lines)
{
  string Pattern = @"(?<Date>\d{4}-\d{2}-\d{2})(?:,)(?<Time>\d{2}:\d{2}:\d{2})(?:,)(?<EAN>\d*)";
  Regex R = new Regex(Pattern);
  Match m = R.Match(line);
  items.Add(new List() { Date = m.Groups["Date"].ToString(),
  Time = m.Groups["Time"].ToString(), EAN = m.Groups["EAN"].ToString() });
}			
LvItems.ItemsSource = items;


Now I want to be able to count if there are any duplicates, and show the results in a new ListView like this:
(| shows new Column in the gridview)
1578456329781|1
1578453697235|3
1548795358155|1


Does anyone have a better idea than using a atleast two loops to do this?

I was thinking on using one loop to go threw the list, and then use the second loop to check for duplicates and count.
Wondering if there are a simplier solution for this.

Any help, as always, are much appreciated.
Have a nice day!
Have gotten a new IDE Smile | :)


modified 25-Aug-20 10:14am.

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 
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 
AnswerRe: PowerApps and C# Pin
Dave Kreskowiak17-Aug-20 7:42
mveDave Kreskowiak17-Aug-20 7:42 
QuestionBinding picture box with column with oracle Pin
mohammed alherwi14-Aug-20 23:26
mohammed alherwi14-Aug-20 23:26 
AnswerRe: Binding picture box with column with oracle Pin
Eddy Vluggen22-Aug-20 10:11
professionalEddy Vluggen22-Aug-20 10:11 
QuestionHow to Read and Write to RFID(v9t557) as Human Interface Device C# Pin
Member 1177073713-Aug-20 14:10
Member 1177073713-Aug-20 14:10 
AnswerRe: How to Read and Write to RFID(v9t557) as Human Interface Device C# Pin
Dave Kreskowiak13-Aug-20 16:28
mveDave Kreskowiak13-Aug-20 16:28 
GeneralRe: How to Read and Write to RFID(v9t557) as Human Interface Device C# Pin
Member 1177073714-Aug-20 12:40
Member 1177073714-Aug-20 12:40 
GeneralRe: How to Read and Write to RFID(v9t557) as Human Interface Device C# Pin
Dave Kreskowiak14-Aug-20 13:16
mveDave Kreskowiak14-Aug-20 13:16 

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.