Console closes before showing result [duplicate]












0















This question already has an answer here:




  • Why is the console window closing immediately once displayed my output?

    19 answers




using System;
public class Exercise6
{
public static void Main()
{

int x,y,z;

Console.Write("First number:");
x = Convert.ToInt32(Console.ReadLine());

Console.Write("nSecond number:");
y = Convert.ToInt32(Console.ReadLine());

Console.Write("nThird number:");
z = Convert.ToInt32(Console.ReadLine());

int res1 = ((x + y) * z);
Console.WriteLine(res1);
}


}



So I would like it if it would display "res1" on the console, but instead it just closes. How can I stop the console from closing?










share|improve this question













marked as duplicate by Community Nov 22 at 18:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • If you are starting it from Visual Studio use Ctrl+F5 instead of F5 to run it.
    – ckuri
    Nov 22 at 18:43










  • Ctrl+F5 starts without debugging, which isn't necessarily bad, but could be confusing
    – Broom
    Nov 22 at 18:45
















0















This question already has an answer here:




  • Why is the console window closing immediately once displayed my output?

    19 answers




using System;
public class Exercise6
{
public static void Main()
{

int x,y,z;

Console.Write("First number:");
x = Convert.ToInt32(Console.ReadLine());

Console.Write("nSecond number:");
y = Convert.ToInt32(Console.ReadLine());

Console.Write("nThird number:");
z = Convert.ToInt32(Console.ReadLine());

int res1 = ((x + y) * z);
Console.WriteLine(res1);
}


}



So I would like it if it would display "res1" on the console, but instead it just closes. How can I stop the console from closing?










share|improve this question













marked as duplicate by Community Nov 22 at 18:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • If you are starting it from Visual Studio use Ctrl+F5 instead of F5 to run it.
    – ckuri
    Nov 22 at 18:43










  • Ctrl+F5 starts without debugging, which isn't necessarily bad, but could be confusing
    – Broom
    Nov 22 at 18:45














0












0








0








This question already has an answer here:




  • Why is the console window closing immediately once displayed my output?

    19 answers




using System;
public class Exercise6
{
public static void Main()
{

int x,y,z;

Console.Write("First number:");
x = Convert.ToInt32(Console.ReadLine());

Console.Write("nSecond number:");
y = Convert.ToInt32(Console.ReadLine());

Console.Write("nThird number:");
z = Convert.ToInt32(Console.ReadLine());

int res1 = ((x + y) * z);
Console.WriteLine(res1);
}


}



So I would like it if it would display "res1" on the console, but instead it just closes. How can I stop the console from closing?










share|improve this question














This question already has an answer here:




  • Why is the console window closing immediately once displayed my output?

    19 answers




using System;
public class Exercise6
{
public static void Main()
{

int x,y,z;

Console.Write("First number:");
x = Convert.ToInt32(Console.ReadLine());

Console.Write("nSecond number:");
y = Convert.ToInt32(Console.ReadLine());

Console.Write("nThird number:");
z = Convert.ToInt32(Console.ReadLine());

int res1 = ((x + y) * z);
Console.WriteLine(res1);
}


}



So I would like it if it would display "res1" on the console, but instead it just closes. How can I stop the console from closing?





This question already has an answer here:




  • Why is the console window closing immediately once displayed my output?

    19 answers








c# console






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 18:38









SSA

1




1




marked as duplicate by Community Nov 22 at 18:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Community Nov 22 at 18:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • If you are starting it from Visual Studio use Ctrl+F5 instead of F5 to run it.
    – ckuri
    Nov 22 at 18:43










  • Ctrl+F5 starts without debugging, which isn't necessarily bad, but could be confusing
    – Broom
    Nov 22 at 18:45


















  • If you are starting it from Visual Studio use Ctrl+F5 instead of F5 to run it.
    – ckuri
    Nov 22 at 18:43










  • Ctrl+F5 starts without debugging, which isn't necessarily bad, but could be confusing
    – Broom
    Nov 22 at 18:45
















If you are starting it from Visual Studio use Ctrl+F5 instead of F5 to run it.
– ckuri
Nov 22 at 18:43




If you are starting it from Visual Studio use Ctrl+F5 instead of F5 to run it.
– ckuri
Nov 22 at 18:43












Ctrl+F5 starts without debugging, which isn't necessarily bad, but could be confusing
– Broom
Nov 22 at 18:45




Ctrl+F5 starts without debugging, which isn't necessarily bad, but could be confusing
– Broom
Nov 22 at 18:45












1 Answer
1






active

oldest

votes


















0














If you add another call to Console.ReadLine(), the console window will stay open until you hit enter.



using System;
public class Exercise6
{
public static void Main()
{

int x,y,z;

Console.Write("First number:");
x = Convert.ToInt32(Console.ReadLine());

Console.Write("nSecond number:");
y = Convert.ToInt32(Console.ReadLine());

Console.Write("nThird number:");
z = Convert.ToInt32(Console.ReadLine());

int res1 = ((x + y) * z);
Console.WriteLine(res1);
Console.ReadLine();
}





share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If you add another call to Console.ReadLine(), the console window will stay open until you hit enter.



    using System;
    public class Exercise6
    {
    public static void Main()
    {

    int x,y,z;

    Console.Write("First number:");
    x = Convert.ToInt32(Console.ReadLine());

    Console.Write("nSecond number:");
    y = Convert.ToInt32(Console.ReadLine());

    Console.Write("nThird number:");
    z = Convert.ToInt32(Console.ReadLine());

    int res1 = ((x + y) * z);
    Console.WriteLine(res1);
    Console.ReadLine();
    }





    share|improve this answer


























      0














      If you add another call to Console.ReadLine(), the console window will stay open until you hit enter.



      using System;
      public class Exercise6
      {
      public static void Main()
      {

      int x,y,z;

      Console.Write("First number:");
      x = Convert.ToInt32(Console.ReadLine());

      Console.Write("nSecond number:");
      y = Convert.ToInt32(Console.ReadLine());

      Console.Write("nThird number:");
      z = Convert.ToInt32(Console.ReadLine());

      int res1 = ((x + y) * z);
      Console.WriteLine(res1);
      Console.ReadLine();
      }





      share|improve this answer
























        0












        0








        0






        If you add another call to Console.ReadLine(), the console window will stay open until you hit enter.



        using System;
        public class Exercise6
        {
        public static void Main()
        {

        int x,y,z;

        Console.Write("First number:");
        x = Convert.ToInt32(Console.ReadLine());

        Console.Write("nSecond number:");
        y = Convert.ToInt32(Console.ReadLine());

        Console.Write("nThird number:");
        z = Convert.ToInt32(Console.ReadLine());

        int res1 = ((x + y) * z);
        Console.WriteLine(res1);
        Console.ReadLine();
        }





        share|improve this answer












        If you add another call to Console.ReadLine(), the console window will stay open until you hit enter.



        using System;
        public class Exercise6
        {
        public static void Main()
        {

        int x,y,z;

        Console.Write("First number:");
        x = Convert.ToInt32(Console.ReadLine());

        Console.Write("nSecond number:");
        y = Convert.ToInt32(Console.ReadLine());

        Console.Write("nThird number:");
        z = Convert.ToInt32(Console.ReadLine());

        int res1 = ((x + y) * z);
        Console.WriteLine(res1);
        Console.ReadLine();
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 at 18:41









        Broom

        460215




        460215















            Popular posts from this blog

            What visual should I use to simply compare current year value vs last year in Power BI desktop

            Alexandru Averescu

            Trompette piccolo