To create generic methods I find it easier to actually create the method by generating the code from the method I would normally use to call them. (Right click then refactor)
static void Swap(ref T item1, ref T item2)
{
T temp;
temp = item1;
item1 = item2;
item2 = temp;
}
And the call to this class would be something like this…
private void Form1_Load(object sender, EventArgs e)
{
string first = "Hi";
string last = "Bill";
Swap(ref first,ref last);
MessageBox.Show(first);
MessageBox.Show(last);
}
