You are on page 1of 1

Array

public partial class Form1 : Form


{
int[] numeros = { 10, 20, 30, 40, 50 };
string[] letras = { "A", "B", "C", "D", "E" };

public Form1()
{
InitializeComponent();
}

private void btMostrarN_Click(object sender, EventArgs e)


{
int pos = Convert.ToInt32(txPos.Text);
lbInfo.Text = "Na posição " + txPos.Text + " está o número:";
txResN.Text = numeros[pos].ToString();;
}

private void btMostraL_Click(object sender, EventArgs e)


{
int pos = Convert.ToInt32(txPos.Text);
lbInfo.Text = "Na posição " + txPos.Text + " está a letra:";
txResN.Text = letras[pos];
}

private void btMostrarNL_Click(object sender, EventArgs e)


{
int pos = Convert.ToInt32(txPos.Text);
lbInfo.Text = "Na posição " + txPos.Text + " estão:";
txResN.Text = numeros[pos] + " " + letras[pos];
}

private void btGravaN_Click(object sender, EventArgs e)


{
numeros[0] = Convert.ToInt32(txDados.Text);
}

private void btGravaL_Click(object sender, EventArgs e)


{
letras[0] = txDados.Text;
}

private void btLimpar_Click(object sender, EventArgs e)


{
for (int indice = 0; indice < numeros.Count(); indice++)
numeros[indice] = 0;

for (int indice = 0; indice < letras.Count(); indice++)


letras[indice] = "N/D";
}
1 de 1

You might also like