0

I am making a column in my table as History which needs to store data like below:

28/05/2013: Service_Id = 1, Mapping_Id = 3, Comment = abcxyz
29/05/2013: Service_Id = 1, Mapping_Id = 3, Comment = changeddata

Now I don't know how to make data look like this that is with line break in c# code so that it is stored in sql server and when I retrieve data it should look like above only.

4

2 回答 2

2

试试看

// Sample for the Environment.NewLine property 
 using System;

 class Sample 
 {
   public static void Main() 
   {
      Console.WriteLine();
      Console.WriteLine("NewLine: {0}  first line{0}  second line{0}  third line",
                      Environment.NewLine);
   }
 }
/*
 This example produces the following results:

 NewLine:
 first line
 second line
 third line
*/

参考

堆栈溢出参考

于 2013-05-29T07:27:56.673 回答
1

您可以仅与 连接Environment.NewLine,或用于StringBuilder附加行。

它不一定在 SQL 中看起来像 Management Studio,因为字段不是以这种方式显示的,但是在任何显示内容的地方,只要尊重换行符,它就会被格式化。

于 2013-05-29T07:11:01.173 回答