0% found this document useful (0 votes)
39 views2 pages

Private Void Object Int: Eventargs

This document contains code examples demonstrating basic operations, if/else statements, switch statements, and do-while loops in C#: 1) The code includes examples of adding and subtracting two numbers inputted as text, and displaying the result. 2) Examples are shown of if/else statements to compare two numbers and identify the larger, and to evaluate a number and return a shape name. 3) A switch statement is used to run different code blocks based on a number input, including a for loop, do-while loop, and if/else evaluation. 4) Four variations of the do-while loop are demonstrated to count up and down in increments of 1 and 2.

Uploaded by

Debora Sales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

Private Void Object Int: Eventargs

This document contains code examples demonstrating basic operations, if/else statements, switch statements, and do-while loops in C#: 1) The code includes examples of adding and subtracting two numbers inputted as text, and displaying the result. 2) Examples are shown of if/else statements to compare two numbers and identify the larger, and to evaluate a number and return a shape name. 3) A switch statement is used to run different code blocks based on a number input, including a for loop, do-while loop, and if/else evaluation. 4) Four variations of the do-while loop are demonstrated to count up and down in increments of 1 and 2.

Uploaded by

Debora Sales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Operaciones Basicas

private void button1_Click(object sender, EventArgs e)


{
int n1, n2, r;
n1 = Convert.ToInt32(txtn1.Text);
n2 = Convert.ToInt32(txtn2.Text);
r = n1 + n2;
txtvr.Text = Convert.ToString(r);
}

private void button2_Click(object sender, EventArgs e)


{
int n1, n2, r;
n1 = Convert.ToInt32(txtn1.Text);
n2 = Convert.ToInt32(txtn2.Text);
r = n1 - n2;
txtvr.Text = Convert.ToString(r);
}

IF simple 2 ingresos
{
int n1, n2;
string r;
n1 = Convert.ToInt32(txtn1.Text);
n2 = Convert.ToInt32(txtn2.Text);
if (n1 > n2)
{ r = "Primero Mayor"; }
else
{ r = "Segundo Mayor"; }
txtr.Text = r;
}

IF compuesto
{
int l;
string r;
l = Convert.ToInt32(txtl.Text);
if (l == 3)
{ r = "Triangulo"; }
else if (l == 4)
{ r = "Cuadrado"; }
else
{ r = "No hay Figura"; }
txtf.Text = r;
}

IF anidado
Switch con Multiples casos de ciclos e IF
{
int a;
a = Convert.ToInt32(textBox2.Text);
switch (a)
{
case 1:
int b;
for (b = 0; b <= 10; b++)
{ txtvr.AppendText(a + "Hola Mundo"); }
break;

case 2:
int c;
c = 0;
do
{
txtvr.AppendText(c + " ");
c++;
} while (c <= 20);
break;

case 3:
int l;
string r;
l = Convert.ToInt32(txtl.Text);
if (l == 3)
{ r = "Triangulo"; }
else if (l == 4)
{ r = "Cuadrado"; }
else if ( l == 5)
{ r = "Pentagono"; }
else
{ r = "NO hay Figura"; }
txtvr.Text = r;
break;
}

Ciclo Do While en sus 4 formas


{
int a;
a = 0;
do
{
listBox1.Items.Add(a + " ");
a++;
} while (a <= 20);
int b;
b = 20;
do
{
listBox2.Items.Add(b + " ");
b--;
} while (b >= 0);
int c;
c = 0;
do
{
listBox3.Items.Add(c + " ");
c = c + 2;
} while (c <= 20);
int d;
d = 20;
do
{
listBox4.Items.Add(d + " ");
d = d - 2;
} while (d >= 0);
}

You might also like