Greetings,
I am having some kind of trouble with some code. I have the following object
My code is:
What I am doing is filling two two Arrays of this objects and then trying to substract ArrayA from ArrayB, but it doesn't. Anyone knows why?
Thanks
I am having some kind of trouble with some code. I have the following object
Code:
using System;
using System.Collections;
namespace ImageServerCleanup
{
public class DiffList : CollectionBase
{
public Diff this[int index]
{
get
{
return ((Diff)(List[index]));
}
set
{
List[index] = value;
}
}
public int Add( Diff value )
{
return( List.Add( value ) );
}
public int IndexOf( Diff value )
{
return( List.IndexOf( value ) );
}
public void Insert( int index, Diff value )
{
List.Insert( index, value );
}
public void Remove( Diff value )
{
List.Remove( value );
}
public bool Contains( Diff value )
{
return( List.Contains( value ) );
}
public class Diff
{
private string _path;
private string _filename;
public Diff(string path, string filename)
{
this._path = path;
this._filename = filename;
}
public Diff()
{
}
public string Path
{
get
{
return _path;
}
set
{
_path = value;
}
}
public string Filename
{
get
{
return _filename;
}
set
{
_filename = value;
}
}
}
}
}
Code:
DiffList ArrayA = new DiffList();
for(int row = 0; row < rowCount; row++)
{
DiffList.Diff entry = new DiffList.Diff();
entry.Path = data1.ToString().ToLower();
entry.Filename = data2.ToString().ToLower();
ArrayA.Add(entry);
}
DiffList ArrayB = new DiffList();
for(int row = 0; row < rowCount; row++)
{
DiffList.Diff entry = new DiffList.Diff();
entry.Path = data3.ToString().ToLower();
entry.Filename = data4.ToString().ToLower();
ArrayB.Add(entry);
}
foreach (DiffList.Diff fileToRemove in ArrayA)
{
ArrayB.Remove(fileToRemove);
}
Thanks
Comment