using System; public class GenericMethods { // Swap generic method. public static void Swap( ref AnyType lhs, ref AnyType rhs ) { AnyType tmp = lhs; lhs = rhs; rhs = tmp; } // Exercise the Swap generic method public static void Main( string[ ] args ) { int x = 5; int y = 7; double a = 2; double b = 4; Swap( ref x, ref y ); // Uses Swap Swap( ref a, ref b ); // Uses Swap Console.WriteLine( "x=" + x + " y=" + y ); Console.WriteLine( "a=" + a + " b=" + b ); // Swap( ref x, ref b ); // Illegal: no match } }