Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   C (https://www.askmehelpdesk.com/forumdisplay.php?f=438)
-   -   How to change change a form in c# to consloe (https://www.askmehelpdesk.com/showthread.php?t=808058)

  • Feb 9, 2015, 11:42 AM
    adam1998
    How to change change a form in c# to consloe
    Hi
    I have created a program in C# using form I want to change it to console but I can't seem to get it right, here is the code
    static void Main() {
    Application.EnableVisualStyles();
    Application.Run(new Form());


    namespace Triangle_Dimensions
    {
    public partial class Program : Form
    {
    public Form1()
    {
    InitializeComponent();
    }


    private void btnPerimeter_Click(object sender, EventArgs e)
    {
    decimal side1 = decimal.Parse(txtside1.Text);


    decimal side2 = decimal.Parse(txtside2.Text);


    decimal side3 = decimal.Parse(txtside3.Text);
    decimal perimeter;
    perimeter = side1 + side2 + side3;
    MessageBox.Show("The perimeter of the triangle is " + perimeter +"cm", " Triangle Perimeter Calculation");










    }


    private void btnArea_Click(object sender, EventArgs e)
    {
    decimal height = decimal.Parse(txtHeight.Text);


    decimal Base = decimal.Parse(txtBase.Text);




    decimal area;
    area = Base * height / 2;
    MessageBox.Show("The area of the triangle is " + area + " cm square", " Triangle Area Calculation");


    }


    private void btnHeight_Click(object sender, EventArgs e)
    {
    decimal area = decimal.Parse(txtArea.Text);


    decimal Base = decimal.Parse(txtBaseT.Text);




    decimal height;
    height = area * 2 / Base ;
    MessageBox.Show("The height of the triangle is " + height + " cm cubic", " Triangle Height Calculation");


    }


    private void btnReset_Click(object sender, EventArgs e)
    {
    txtside1.Clear();
    txtside2.Clear();
    txtside3.Clear();
    txtArea.Clear();


    txtBase.Clear();
    txtBaseT.Clear();
    txtHeight.Clear();



    }
    }
    }

    I have changed messageBox.show to console.read but I keep getting errors could I get some help in this please.

  • All times are GMT -7. The time now is 06:01 AM.