Mark Dawson
Hi,
if I understand what you are asking correctly, you can achieve what you want by using the ref keyword to pass a parameter to a function by reference rather thn by value, therefore inside the function you can change what the original reference points to e.g.:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MyClass start = new MyClass("start");
MyClass end = new MyClass("end");
Foo(ref start, ref end);
//Output => start.Name=end, end.Name=end
Console.WriteLine("start.Name={0}, end.Name={1}", start.Name, end.Name);
}
private static void Foo(ref MyClass mid1, ref MyClass mid2)
{
mid1 = mid2;
}
}
class MyClass
{
private string name;
public MyClass(string name) { this.name = name; }
public string Name { get { return this.name; } }
}
}
Mark.