Bu program ile textbox'a girdiğimiz bir sayıyı bit bit düzeyine dönüştürebiliriz.
Formumuza 2 textbox ve 1 button ekliyoruz buttonun click olayına aşağıdaki kodu yazıyoruz.
**** = vo id (boşluksuz)
Formumuza 2 textbox ve 1 button ekliyoruz buttonun click olayına aşağıdaki kodu yazıyoruz.
**** = vo id (boşluksuz)
Kod:
private **** button1_Click(object sender, EventArgs e)
{
textBox2.Text = "";
int sayi, t;
sayi = Convert.ToInt32(textBox1.Text);
for (t = 128; t > 0; t = t / 2)
{ if ((sayi & t) != 0) textBox2.Text += "1";
if ((sayi & t) == 0) textBox2.Text += "0";
}
}
private **** button1_Click(object sender, EventArgs e)
{
textBox2.Text = "";
int sayi, t;
sayi = Convert.ToInt32(textBox1.Text);
for (t = 128; t > 0; t = t / 2)
{ if ((sayi & t) != 0) textBox2.Text += "1";
if ((sayi & t) == 0) textBox2.Text += "0";
}
}