Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Display result with Console Application

I write a class in C# and I want to display in console. But i can't display it.

My program doesn't have any errors, which means the program runs it but i can't see a result :(

Please help me regarding this problem.

like image 856
Hamid Avatar asked Dec 30 '12 10:12

Hamid


People also ask

How do I show console output in Visual Studio?

Press F11 . Visual Studio calls the Console. WriteLine(String, Object, Object) method. The console window displays the formatted string.

What method is used to print data in console by reading it from application elements?

WriteLine() or Console. Write(), basically both methods are used to print output of console.

How do I use console application?

The first step is to create a new application. Open a command prompt and create a new directory for your application. Make that the current directory. Type the command dotnet new console at the command prompt.

How do you print to console in CS GO?

To print a message to the console, we use the WriteLine method of the Console class. The class represents the standard input, output, and error streams for console applications. Note that Console class is part of the System namespace. This line was the reason to import the namespace with the using System; statement.


2 Answers

You can use Console.WriteLine(Object) to print the output, and Console.Read() to wait for user input.

Console.WriteLine("Hello world");
Console.WriteLine("Press any key to exit.");
Console.Read();

Without Console.Read, sometimes output just comes, and program exits in a flash. So Output cannot be seen/verified easily.

like image 173
Tilak Avatar answered Oct 08 '22 12:10

Tilak


No Problem, I get what you are asking...

In regards to Microsoft Visual Studio 2010

  1. Write Console.WriteLine("Where are you console?"); somewhere in your code - make sure you will definitely see it..

  2. Press Debug button (or the play button)

  3. In the Microsoft Visual Studio, Go to Debug -> Windows -> Output

A small 'Output' Windows should pop up and you can see your console write statements! - Obviously you gotta run the code and it will appear.

Hope it helps!

like image 37
jonprasetyo Avatar answered Oct 08 '22 12:10

jonprasetyo