Console closes before showing result [duplicate]
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?
c# console
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.
add a comment |
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?
c# console
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
add a comment |
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?
c# console
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
c# console
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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();
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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();
}
add a comment |
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();
}
add a comment |
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();
}
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();
}
answered Nov 22 at 18:41
Broom
460215
460215
add a comment |
add a comment |
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