Hi,
I don't think you can pass an obj and mess up data members. Passing the object allows you to access to another classes methods. For example:
class Class1
int Age = 37;
public void Display()
{
Console.WriteLine("Name: {0}\nSSN: {1}\nYour birthyear was: {2}", myName, mySSN, BirthYear.birthYear(this));
}
public class BirthYear
{
public static int birthYear(Class1 obj1)
{
return (2003 - obj1.myAge);
}
}
the object was created in Main and used to access the Display() method. The diplay method needs to call the birthYear() method but it is in a seperate class. We then can use the "this" keyword to pass the current object to the birthYear() method with a variable from the Class1 class.
I hope this helps...
Ray B.
|