question

Santosh-4171 avatar image
0 Votes"
Santosh-4171 asked TimonYang-MSFT answered

Two new lines in string

I have the following code snippet. I want to add two new lines after variable "automatedComment ". I tried the following way. But its taking only one line after the URL in automatedComment. Please let me know how can I add two lines after URL


         string automatedComment = "<b>Note:</b>" + " Your comment will not be read." +
                                   "For more details, " + "please refer the wiki <URL>";
         string description = automatedComment + Environment.NewLine + "" +
                               "TEST MESSAGE" + Environment.NewLine + "" +
                              Environment.NewLine +
                              Environment.NewLine + "Logs path: " + 
                              Environment.NewLine + 
                              Environment.NewLine + Environment.NewLine + "<b>==== List of Similar " +  " Test Projects With Same issue ====</b>" +
                              Environment.NewLine ;

         description = description.Trim().Trim(Environment.NewLine.ToCharArray());

         description = "<p>" +  + description.Replace(Environment.NewLine, "</p><p>") + "</p>";

Kindly waiting for your inputs.

Thanks,
Santosh


dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

Try using one or more "<br/>" instead of Environment.NewLine. If you cannot change the first part, then use something like 'description = description.Replace(Environment.NewLine, "<br/>").


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TimonYang-MSFT avatar image
0 Votes"
TimonYang-MSFT answered

This should be an html problem.

It is best not to use <p></p> to create a new line, even if you need to use it for some reason, it should be <p>&nbsp;</p>.

However, this method is not recommended. It is better to use <br/> according to Viorel-1's suggestion.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.