Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Aula_21._05._2015
- {
- class Program
- {
- class Aluno
- {
- private int _matricula;
- private string _nome;
- public int matricula
- {
- get { return _matricula; }
- set {_matricula = value;}
- }
- public string nome
- {
- get { return _nome; }
- set {_nome = value;}
- }
- }
- class Cadastro // INDEXADOR
- {
- private Aluno[] VetorAlunos = new Aluno[3];
- public Aluno this[int i]
- {
- get { return VetorAlunos[i]; }
- set { VetorAlunos[i] = value; }
- }
- }
- static void Main(string[] args)
- {
- Cadastro MeuCadastro = new Cadastro();
- Aluno X;
- X = new Aluno();
- X.matricula = 123;
- X.nome = "Bernardo";
- MeuCadastro[0] = X;
- X = new Aluno();
- X.matricula = 456;
- X.nome = "Aline";
- MeuCadastro[1] = X;
- X = new Aluno();
- X.matricula = 789;
- X.nome = "Marta";
- MeuCadastro[2] = X;
- for (int i = 0; i < 3; i++)
- {
- Console.WriteLine("{0} - {1}", MeuCadastro[i].matricula,MeuCadastro[i].nome);
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement