• 0

[C#] Multi-line Console.WriteLine()


Question

I just recently starting learning C# in my Game Development class. I wanted to create a console program that includes a multitude of ASCII art. My current method of entering ASCII art in the code is:

Console.WriteLine("XXXXXXXXXXXX");
Console.WriteLine("XXXXXXXXXXXXXXXXX")

One of my friends told me that it is possible to include multiple lines within one syntax and variable. However, he forgot how. Do any of you guys know how?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

string myString = @"This is the first line of my string.
This is the second line of my string.
This is the third line of the string.";
Console.WriteLine(myString);

or

string myString = "This is the first line of my string.\n" +
				  "This is the second line of my string.\n" +
				  "This is the third line of the string.\n";
Console.WriteLine(myString);

http://msdn.microsoft.com/en-us/library/aa287596(VS.71).aspx

Link to comment
Share on other sites

  • 0
string myString = @"This is the first line of my string.
This is the second line of my string.
This is the third line of the string.";
Console.WriteLine(myString);

That's looks good. I'll try it out. Thanks.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.