object value changes when another object is manipualated.

my MultiplyRow function works fine and returns void. But as n is manipulated , m changes. Even though n was asigned to m before n was manipulated.
I want to make it to where the values inside m don't change.
thanks. here's the code

private static void AddMultipleOfRowTo(Matrix m)
{

Matrix n = m;
MultiplyRow(n);


bool f = false;
string choice;
int row = 0;
bool invalidChoice = false;
Console.WriteLine("Which row would you like to add this row to.");
while (!f)
{
choice = Console.ReadLine();
try
{
row = Convert.ToInt32(choice);
if (row < 1 || row > m.Elements.GetLength(0))
invalidChoice = true;
else
{
f = true;
}
}
catch
{
Console.WriteLine("Your input must be an integer.");
Console.WriteLine("Try again.");
f = false;
}
if (invalidChoice == true)
{
Console.WriteLine("Your choice was invalid.");
Console.WriteLine("Please read your options.");
}
}

for (int i = 0; i < m.Elements.GetLength(0); i++)
{
m.Elements[row - 1, i] = (n.Elements[row - 1, i]) + (m.Elements[row - 1, i]);
}

}
[1847 byte] By [kevinskrazyklub] at [2007-11-20 11:01:31]
# 1 Re: object value changes when another object is manipualated.
The thing is that "m" is just a pointer to where the object actually is in the memory, so when you write "n = m;" n becomes a pointer to the same location. This is how classes work.
You can
1) Make a method to duplicate your object inside your Matrix class.
2) Make it a struct.
3) Make a new object and duplicate the variables inside.
Homogenn at 2007-11-9 11:36:08 >