Alex Watts
Alex Watts

Reputation: 567

New Lines in Visual Studio C# output

I'm working on some code which takes time sheet information and outputs it to a Word Document for employees to turn in at the end of each week. One section of the documents lists what week number it is and then underneath it should display the beginning and end dates of the week (i.e. 1/1/2015 - 1/7/2015); however, when I use the Environment.NewLine to create a line break, it instead adds spacing between the week number and week dates, rather than a return character for a new line. Thoughts or suggestions?

Here's the snippet that formats this section of the document:

{
    string result = string.Empty;
    result += WeekNo() + Environment.NewLine;  //the line break should happen here
    result += StartDate().ToShortDateString();
}

Upvotes: 0

Views: 257

Answers (1)

Thomas Krojer
Thomas Krojer

Reputation: 1018

My other answer was translated to a comment ...

{
    string result = string.Empty;
    result += WeekNo() + "\v";
    result += StartDate().ToShortDateString();
}

It came frome here: Inserting A Line Break (Not A Paragraph Break) Programatically To A Word Document If this other post is helpful please upvote the poster

Upvotes: 1

Related Questions