Step 2: Set properties of the controls (tools). Step 3: Write the events’ procedures. |
|
Text
to “Volume of Cylinder.”
radius
, height
, and volume
, respectively.
calculate
.
using System; using System.Windows.Forms; namespace WindowsFormsApp3 { public partial class Form1 : Form { public Form1( ) { InitializeComponent( ); } private void Calculate_Click( object sender, EventArgs e ) { double result = int.Parse( radius.Text ) * int.Parse( radius.Text ) * 3.14159 * int.Parse( height.Text ); volume.Text = result.ToString( ); } } }
int.Parse
function converts a string to an interger, and the ToString
performs the opposite function.