I have a list of Buttons and I want to get the two elements that are 'equal':
for (int i = 0; i < Memory.Count; i++ )
{
piezas = Memory.FindAll(s => (s.Name != Memory[i].Name && Utilidades.CompareImage(s.Image, Memory[i].Image)));
}
This is supposed (if I'm not wrong) the list with the two elements that have different Name but are using the same Image. I'm more than sure that such elements exists... but I don't know why this doesn't work.
"Utilidades.CompareImage" is an static method:
public static bool CompareImage(Image firstImage, Image secondImage)
{
MemoryStream ms = new MemoryStream();
firstImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
String firstBitmap = Convert.ToBase64String(ms.ToArray());
ms.Position = 0;
secondImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
String secondBitmap = Convert.ToBase64String(ms.ToArray());
if (firstBitmap.Equals(secondBitmap))
return true;
else
return false;
}
I've tested the method before and it's working as intented.
Can you please help me?