1
I wanted to know how to make a list comparator in C# or bat, to identify only the different items between them
1
I wanted to know how to make a list comparator in C# or bat, to identify only the different items between them
1
- If I understand the question, where do I understand you want to:
1) use a solution in bat/cmd as an option;
2) wants to separate items duplicates and unique of the contents of a file;
- To use, you can pass as target file name argument by the command line, or just drag and drop that target file directly into the cmd/bat.
@echo off & mode con cols=45 lines=8 & cd /d "%~dp0" & color 9f & title Q382159 <nul & set _lf=^
<nul <nul & cd /d "%~dp0" & type nul >"%~dp0Duplicados.log" & type nul >"%~dp0Unicos.log" & echo/
echo/%cmdcmdline%|findstr /i "\.cmd \.bat" 2>nul >nul && set "_1=&echo/no% _lf% Drag ^& Drop " || set "_1=&echo/no% _lf%" Argumento/Parametro"
if /i "%~1^|"=="^|%~1" goto :^(
echo/Comparando conteudo do arquivo... && findstr /ixg:"%~1" "%~1" >>"%~dp0Duplicados.log"
echo/Separando item/linha/conteudo unicos && findstr /vixg:"%~1" "%~1" >>"%~dp0Unicos.log"
set /a _cnt_unico=0, _cnt_multi=0
for %%C in (Duplicados.log Unicos.log) do for /f %%i in ('type "%~dp0%%C"^|find "" /v /c')do echo/Total itens em %%C: %%i
timeout /t -1 & exit /b
:^(
echo/Nenhum arquivo usado informado %_1% & echo/ & echo/Sistema em Pause... & >nul timeout /t -1 && exit /b
| Resulta: |
0
I don’t know if this is exactly what you want, but just so you know where to start:
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
// ------- Criação de Propriedades e Populando elas para o exemplo --------
// Listas
var lst1 = new List<int>();
var lst2 = new List<int>();
// Add itens na lista 1
lst1.Add(1);
lst1.Add(2);
lst1.Add(3);
// Add itens na lista 2
lst2.Add(2);
lst2.Add(4);
// ------- FIM --------
// Compara as listas e add os valores diferentes em outra lista
var lstDiferencas = (lst1.Except(lst2)).Union(lst2.Except(lst1)).ToList();
// Imprime os valores da lista 3 (valores diferentes)
Console.WriteLine("Valores diferentes entre as listas: ");
// Imprime os valores ordenados
foreach (var item in lstDiferencas.OrderBy(x=>x))
Console.WriteLine(item+"; ");
Console.ReadLine();
}
}
Here, practice the above example: https://dotnetfiddle.net/ash9mR
Browser other questions tagged c# batch
You are not signed in. Login or sign up in order to post.
Post what you’ve tried to do so far.
– CypherPotato
Welcome to ONLY, this task would be to compare rum lines a file, and by pointing out the lines and their content that differ from the others?
– It Wasn't Me