Ich bekomme sogar nur 1 raus...
1. mal wandelst du die Text Länge in Double um, wie wärs denn nur mit Text ?!?
2. willst abrunden oder aufrunden ?
weil 75.6... ist 76 gerundet...
C#-Quelltext
1:
| x = Convert.ToInt32(Math.Round((decimal)(Math.Sqrt(Convert.ToDouble(Convert.ToDouble(textBox1.Text) / 3))), 0, MidpointRounding.AwayFromZero)); |
so funktioniert dein Code...
P.S. oder so:
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
| private double y; private double z; private decimal f; private decimal g; private void button1_Click(object sender, EventArgs e) { y = Convert.ToDouble(textBox1.Text); z = Math.Sqrt(y/3); f = (decimal)z; g = Math.Round(f); label1.Text = g.ToString(); } |