Compare private members of two classes

  • Thread starter Thread starter Avi
  • Start date Start date
A

Avi

Hi all,

I have two instances of the same class. Is it possible to compare private
members of two classes and to come with a list of differences?
 
You can write a function

class MyClass
{
private int x = 1;

public bool MyCompare ( MyClass mc )
{
return ( x == mc.x );
}
}

MyClass mc1 = new MyClass ();
MyClass mc2 = new MyClass ();

bool b = mc1.MyCompare ( mc2 );
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top