I have two lists List that i need to combine and removing duplicate values of both lists
A bit hard to explain, so let me show an example of what the code looks like, and what i want as a result, in sample I use int type not ResultadoDeAnalisisFicheroSql class.
first_list = [1, 12, 12, 5]
second_list = [12, 5, 7, 9, 1]
The result of combining the two lists should result in this list: resulting_list = [1, 12, 5, 7, 9]
You'll notice that the result has the first list, including its two "12" values, and in second_list has an additional 12, 1 and 5 value.
ResultadoDeAnalisisFicheroSql class
[Serializable]
public partial class ResultadoDeAnalisisFicheroSql
{
public string FicheroSql { get; set; }
public string RutaFicheroSql { get; set; }
public List<ErrorDeAnalisisSql> Errores { get; set; }
public List<RecomendacionDeAnalisisSql> Recomendaciones { get; set; }
public ResultadoDeAnalisisFicheroSql()
{
}
public ResultadoDeAnalisisFicheroSql(string rutaFicheroSql)
{
if (string.IsNullOrEmpty(rutaFicheroSql)
|| rutaFicheroSql.Trim().Length == 0)
{
throw new ArgumentNullException("rutaFicheroSql", "Ruta de fichero Sql es nula");
}
if (!rutaFicheroSql.EndsWith(Utility.ExtensionFicherosErrorYWarning))
{
throw new ArgumentOutOfRangeException("rutaFicheroSql", "Ruta de fichero Sql no tiene extensión " + Utility.ExtensionFicherosErrorYWarning);
}
RutaFicheroSql = rutaFicheroSql;
FicheroSql = ObtenerNombreFicheroSql(rutaFicheroSql);
Errores = new List<ErrorDeAnalisisSql>();
Recomendaciones = new List<RecomendacionDeAnalisisSql>();
}
private string ObtenerNombreFicheroSql(string rutaFicheroSql)
{
var f = Path.GetFileName(rutaFicheroSql);
return f.Substring(0, f.IndexOf(Utility.ExtensionFicherosErrorYWarning));
}
public override bool Equals(object obj)
{
if (obj == null)
return false;
if (!(obj is ResultadoDeAnalisisFicheroSql))
return false;
var t = obj as ResultadoDeAnalisisFicheroSql;
return t.FicheroSql == this.FicheroSql
&& t.RutaFicheroSql == this.RutaFicheroSql
&& t.Errores.Count == this.Errores.Count
&& t.Recomendaciones.Count == this.Recomendaciones.Count;
}
}
Any sample code for combine and removing duplicates ?