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.
Press F11 . Visual Studio calls the Console. WriteLine(String, Object, Object) method. The console window displays the formatted string.
WriteLine() or Console. Write(), basically both methods are used to print output of console.
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.
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.
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.
No Problem, I get what you are asking...
In regards to Microsoft Visual Studio 2010
Write Console.WriteLine("Where are you console?");
somewhere in your code - make sure you will definitely see it..
Press Debug button (or the play button)
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With