-
-
Save parzibyte/e11972a54f28f2103a8e33883a1fa63c 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
/* | |
https://parzibyte.me/blog | |
*/ | |
using System; | |
namespace App | |
{ | |
class Persona | |
{ | |
public string nombre; | |
public int edad; | |
public Persona(string nombre, int edad) | |
{ | |
this.nombre = nombre; | |
this.edad = edad; | |
} | |
public override string ToString() | |
{ | |
return "Persona con nombre " + this.nombre + " y edad " + this.edad; | |
} | |
public void saludar() | |
{ | |
Console.WriteLine("Me llamo " + this.nombre); | |
} | |
} | |
class Programa | |
{ | |
static void recorrerArreglo(Persona[] personas) | |
{ | |
foreach (var persona in personas) | |
{ | |
Console.WriteLine("Tenemos una persona: " + persona); | |
persona.saludar(); | |
} | |
} | |
static void Main(string[] args) | |
{ | |
Persona[] personas = { new Persona("Luis", 24), new Persona("María", 24) }; | |
recorrerArreglo(personas); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment