Hi I\'m trying to do a simple swap of two objects.My code is
void Main()
{
object First = 5;
object Second = 10;
Swap(First, Second);
//If I display res
You need to pass by reference.
Here's some extra info on pass-by-refence, pass-by-value: http://www.yoda.arachsys.com/csharp/parameters.html, try this:
void Main()
{
object First = 5;
object Second = 10;
Swap(ref First, ref Second);
//If I display results it displays as
//Value of First as 5 and Second as 10
}
private static void Swap(ref object First, ref object Second)
{
object temp = First;
First = Second;
Second = temp;
}