private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0)
{
string sayii = textBox1.Text.Substring(0, textBox1.Text.Length);
uint[] sayicc = new uint[textBox1.Text.Length];


for (int i = 0; i < textBox1.Text.Length; i++)
{
sayicc = Convert.ToUInt32(sayii - 48);


}


uint[] dizi2 = new uint[textBox1.Text.Length];
uint bit = 1;


for (int j = 0; j < textBox1.Text.Length; j++)
{
dizi2[j] = bit;
bit *= 2;
}
Array.Reverse(dizi2);
uint deger = 0;
for (int i = 0; i <= dizi2.Length - 1; i++)
{
dizi2 *= sayicc;


if (sayicc == 1)
{
deger += dizi2;
}
}
textBox2.Text = "  " + deger.ToString();
}
else
{
MessageBox.Show("Deger girilecek alan boş.", "HATA!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Edited 3 Years Ago by Nick Evan: Fixed formatting

In case if you want to get some text, and get it into byte array (or something) and reverse it, then you can try somrtihng like this:

private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length > 0)
            {
                char[] chars = textBox1.Text.ToCharArray();
                Array.Reverse(chars);
                byte[] myBytes = Encoding.UTF32.GetBytes(new string(chars));
                textBox2.Text = Encoding.UTF32.GetString(myBytes, 0, myBytes.Length);
            }
            else
            {
                MessageBox.Show("Deger girilecek alan boş.", "HATA!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

This code for binary to decimal. I didint see like this easy code. The other calculating codes are too long and complex. I made this and you can use easily.

This article has been dead for over six months. Start a new discussion instead.