Declaring a looooong single line string in C#

后端 未结 11 1004
礼貌的吻别
礼貌的吻别 2021-02-05 00:58

Is there a decent way to declare a long single line string in C#, such that it isn\'t impossible to declare and/or view the string in an editor?

The options I\'m aware o

11条回答
  •  -上瘾入骨i
    2021-02-05 01:51

    you can use StringBuilder like this:

    StringBuilder str = new StringBuilder();
    str.Append("this is my really long string.  this is my long string. ");
    str.Append("this is my really long string.  this is my long string. ");
    str.Append("this is my really long string.  this is my long string. ");
    str.Append("this is my really long string.  this is my long string. ");
    string s = str.ToString();
    

    You can also use: Text files, resource file, Database and registry.

提交回复
热议问题