image - C# reference comparison -


Do anyone know what can be wrong, when you have two system.Drawing.Image Organizations trying to compare?

I have some IEnumerable & lt; Image & gt; Image. Using the Forfile (Path) method

But the following code generates the result I can not quite understand:

  foreach (var image1 in images) {foreach (images in var image2) {if (image1 == image2) {// (do something!)}}}   

The thing is that (do something!) The part is never called.

The debugger shows that the image object has a property named nativeImage , which I think is a raw memory pointer, because System.Drawing.Image is implemented using Marshalling.

This memory pointer changes all the time and I think that some kind of cloning is here, but I do not understand what I really need to do.

What I am doing is doing wrong and how do I System.Drawing.Image objects to a IEnumerable & lt; & Gt; to see if they are similar?

Thank you.


update
  var path = new list & lt; String & gt; {"Test / 1_1.jpg", "test / 1_2.jpg"}; IEnumerable & lt; Image & gt; Figure = Path. Select (path = & gt; image.framefile (path)). ToList (); Foreach (image image in the image) {foreach (image image2) in images {if (rectangle (image 1, image 2)} {}}}   

without < Code> ToList () , it does not work clearly, I am very stupid.

Thanks everyone.

Remember that each time you call GetEnumerator Call MoveNext . What you need to do is repetition force in a list.

  var imageList = images.ToList ();    

Comments