Tema1 1) : Using Using Using Using Using Using Using Using Namespace Public Partial Class Public
Tema1 1) : Using Using Using Using Using Using Using Using Namespace Public Partial Class Public
using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Int16 A, B,resultado; private void button1_Click(object sender, EventArgs e) { A = Int16.Parse(textBox1.Text); B = Int16.Parse(textBox2.Text); resultado = Operacion(A, B); textBox3.Text = Convert.ToString(resultado); } Int16 Operacion(Int16 A, Int16 B) { resultado = Convert.ToInt16(A * B); resultado = Convert.ToInt16((resultado + 2) * 5); return resultado; } } }
2) Sin funciones
using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq;
using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { byte A; A = byte.Parse(textBox1.Text); textBox2.Text = Convert.ToString(A, 2); while (textBox2.Text.Length != 8) { textBox2.Text = "0" + textBox2.Text; } A |= 0x01; A |= 0x02; A |= 0x10; A |= 0x20; A |= 0x40; A |= 0x80; textBox2.Text = Convert.ToString(A, 2); } } } 2) using using using using using using using using
namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { byte dato; dato = Convert.ToByte(textBox1.Text); dato = seteo(dato); textBox2.Text = Convert.ToString(dato); } byte seteo(byte dato) { dato = Convert.ToByte(dato | 243); return dato;
} } } 3) using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;
namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { byte A; A = byte.Parse(textBox1.Text); textBox1.Text=Convert.ToString(A,2); while(textBox2.Text.Length!=8) { textBox2.Text="0" + textBox2.Text; } A &= 0x1f; textBox3.Text = Convert.ToString(A, 2); } } }
4)
using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } byte A; private void button1_Click(object sender, EventArgs e)
{ A = byte.Parse(textBox1.Text); textBox2.Text = Convert.ToString(A, 2); while (textBox2.Text.Length != 8) { textBox2.Text = "0" + textBox2.Text; } A ^= 0x01; A ^= 0x02; A ^= 0x40; A ^= 0x80; textBox3.Text = Convert.ToString(A, 2); } } }