Visual Studio 2013 - How to view the output in the console?

I'm new to C # and VS, and I'm just trying to print a line using Console.WriteLine (...), but it only appears on the command line. Is there a way to draw output in the output window instead?

EDIT: This is a console application.

Also, how do I access the command line to run programs? I only managed to figure out how to work with F5, but this will not work if I need to enter arguments.

+3
source share
4 answers

If it is ConsoleApplication, it Console.WriteLinewill write the console. If you use Debug.Print, it will print on the Output tab at the bottom.

, . Project -> [YourProjectName] Properties... -> Debug -> Start Options -> Command line arguments. . , bin\Release bin\Debug cmd , , . , .

+9

, , 2 VS2012. ? . ,

https://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b

, @martynaspikunas.. Console.WriteLine() Debug.WriteLine(), IDE. , .

, .

.

Console.ReadKey();

Program.cs? , .

Console Winforms:

 class MyLogger : System.IO.TextWriter
    {
        private RichTextBox rtb;
        public MyLogger(RichTextBox rtb) { this.rtb = rtb; }
        public override Encoding Encoding { get { return null; } }
        public override void Write(char value)
        {
            if (value != '\r') rtb.AppendText(new string(value, 1));
        }
    }

. , InitializeComponent():

 Console.SetOut(new MyLogger(richTextBox1));

Console.WriteLine() richTextBox.

.

: MyLogger Hans Passant 2010 ,

Bind Console Output RichEdit

+2

:

int main ()
{
    cout << "Hello World" << endl ;

    // Add this line of code before your return statement and the console will stay up
    getchar() ;  

    return 0;
}
0
source
using System;
#region Write to Console
/*2 ways to write to console
 concatenation
 place holder syntax - most preferred
 Please note that C# is case sensitive language.
*/
#region
namespace _2__CShrp_Read_and_Write
{
    class Program
    {
        static void Main(string[] args)
        {

            // Prompt the user for his name
            Console.WriteLine("Please enter your name");

            // Read the name from console
            string UserName = Console.ReadLine();
            // Concatenate name with hello word and print
            //Console.WriteLine("Hello " + UserName);

            //place holder syntax
            //what goes in the place holder{0}
            //what ever you pass after the comma i.e. UserName
            Console.WriteLine("Hello {0}", UserName);
            Console.ReadLine();
        }
    }
}
I hope this helps
0
source

Source: https://habr.com/ru/post/1765475/


All Articles