Hoşgeldin Misafir

C#'da Girilen Bir Sayıyı Başka bir tabana çevirmek

Mutlu GÜNER

5 Eyl 2017
31 Mesaj

Aktiflik

Seviye

Deneyim

TIM / GÖREV:
PHP:
private **** button1_Click(object sender, EventArgs e)
        {
            long x;
            int n;  
            try     
            {
                x = int.Parse(textBox1.Text);
                n = int.Parse(textBox2.Text);
                lblSonuc.Text = tabancevir(x,n);

               
            }
            catch (Exception)
            {
                
                throw; 
            }

        }
        string tabancevir(long x, int n) {
        if(n<2)
            return "-1";
        long b; 
        string s = ""; 
        while (x >= n) { 
            b = x % n;  
            x = x / n; 
            if (b > 9)
                s = (char)(55 + b) + s;
            else
                s = b + s; 
        
        
        }
        
        if (x > 9)
s = (char)(55 + x) + s;
else
s = x + s;
return s;
}

        }
    }