// ===++===
//
// OrtizOL
//
// ===--===
/*============================================================
//
// Clase: DemoMetodoGenerico.cs
//
// Propósito: Demostrar la declaración y uso de un método
// genérico.
//
============================================================*/
using System;
namespace Articulos.Cap03
{
internal class DemoMetodoGenerico
{
public static void Alternar<T>(ref T valor1, ref T valor2)
{
T temp = valor1;
valor1 = valor2;
valor2 = temp;
}
public static void Main()
{
int a = 2;
int b = 3;
Console.WriteLine("\nAntes de invocar a `Alternar`:");
Console.WriteLine("\tValor de `a`: {0} - Valor de `b`: {1}", a.ToString(), b.ToString());
Alternar<int>(ref a, ref b);
Console.WriteLine("\nDespués de invocar a `Alternar`:");
Console.WriteLine("\tValor de `a`: {0} - Valor de `b`: {1}\n", a.ToString(), b.ToString());
}
}
}
Ly8gPT09Kys9PT0KLy8KLy8JT3J0aXpPTAovLwovLyA9PT0tLT09PQovKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQovLwovLyBDbGFzZTogRGVtb01ldG9kb0dlbmVyaWNvLmNzCi8vCi8vIFByb3DDs3NpdG86IERlbW9zdHJhciBsYSBkZWNsYXJhY2nDs24geSB1c28gZGUgdW4gbcOpdG9kbyAKLy8gZ2Vuw6lyaWNvLgovLwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLwoKdXNpbmcgU3lzdGVtOwoKbmFtZXNwYWNlIEFydGljdWxvcy5DYXAwMwp7CglpbnRlcm5hbCBjbGFzcyBEZW1vTWV0b2RvR2VuZXJpY28KCXsKCQlwdWJsaWMgc3RhdGljIHZvaWQgQWx0ZXJuYXI8VD4ocmVmIFQgdmFsb3IxLCByZWYgVCB2YWxvcjIpCgkJewoJCQlUIHRlbXAgPSB2YWxvcjE7CgkJCXZhbG9yMSA9IHZhbG9yMjsKCQkJdmFsb3IyID0gdGVtcDsKCQl9CgkJCgkJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJC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