private void bt_Calc_Click(object sender, EventArgs e) { double Raio, Altura; if ((double.TryParse(tx_Raio.Text, out Raio) && double.TryParse(tx_Altura.Text, out Altura))) { if (Raio > 0 && Altura > 0) { double Volume = Math.PI * Math.Pow(Raio, 2) * Altura; tx_Volume.Text = Volume.ToString("N4"); lb_r.Text = "r = " + Raio.ToString(); lb_h.Text = "h = " + Altura.ToString(); lb_Vol.Text = "Vol = " + Volume.ToString("N4"); } else { MessageBox.Show("Digite valores maiores do que 0!"); } } else { MessageBox.Show("Dados Inválidos, digite dados Numéricos!"); } }
static void Main(string[] args) { Raio raio = new Raio(); raio.Executar(); }