-
-
Save parzibyte/0a4713bdb76d11d8b7888a0d5b02533e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace App | |
{ | |
class Persona | |
{ | |
public string nombre; | |
public Persona(string nombre) | |
{ | |
this.nombre = nombre; | |
} | |
public override string ToString() | |
{ | |
return "Persona con nombre " + this.nombre; | |
} | |
} | |
class Programa | |
{ | |
static void recorrerArregloGenerico<T>(IList<T> arreglo) | |
{ | |
foreach (var elemento in arreglo) | |
{ | |
Console.WriteLine(elemento); | |
} | |
} | |
/* | |
https://parzibyte.me/blog | |
*/ | |
static void Main(string[] args) | |
{ | |
int[] numeros = { 999, 28, 11, 96, 1, 2, 45, 0, 1 }; | |
string[] cadenas = { "Hola", "Mundo" }; | |
Persona[] personas = { new Persona("Luis"), new Persona("María") }; | |
recorrerArregloGenerico(numeros); | |
recorrerArregloGenerico(cadenas); | |
recorrerArregloGenerico(personas); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment