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);
}
}

Recommended Answers

Hi,
with all due respect, would you mind telling us the issue of this code?

thx in advance.

Jump to Post

All 4 Replies

Hi,
with all due respect, would you mind telling us the issue of this code?

thx in advance.

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.

Good i haven't see the code so easy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.