Projekt Umrechner Zahlensysteme

Umrechnung Binär -> Dezimal Variante 2

        if(textBox_bin.TextLength>0)
            {
                int dez = 0;
                int ziffer = 0;
                int dezzahl = 0;
                int i = 0;
                string bin = textBox_bin.Text;
                int binzahl = int.Parse(textBox_bin.Text);
                while(binzahl>0)
                {
                    ziffer = binzahl % 10;
                    binzahl = binzahl / 10;
                    dezzahl = dezzahl + ziffer * (int)Math.Pow(2, i);
                    i++;
                }
                Console.Out.WriteLine(dezzahl);
            }