This is the program in question:
namespace TestStuff
{
public class Test
{
public int x;
}
class Program
{
static void Main(string[] args)
{
Test firstClass = new Test();
firstClass.x = 5;
Test secondClass = firstClass;
firstClass.x = 6;
Console.WriteLine(secondClass.x);
}
}
}
The output of this program is 6, I assume this is because Test secondClass = firstClass;
, makes secondClass point to firstClass instead of making a copy of firstClass. If i want to make secondClass a copy of firstClass, how would I go about that ?