using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace binary
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
static string ToBinary(int number)
{
int mod;
string result = string.Empty;
while (number > 0)
{
mod = number % 2;
number /= 2;
result = mod.ToString() + result;
}
return result.PadLeft(8, '0');
}
private void button1_Click(object sender, EventArgs e)
{
int sayi = Int32.Parse(textBox1.Text);
double binary = Convert.ToDouble(ToBinary(sayi));
label2.Text = binary.ToString();
}
}
}
0 yorum:
Yorum Gönder