エディターで文字列を宣言および/または表示することが不可能ではないような、C# で長い単一行文字列を宣言する適切な方法はありますか?
私が知っているオプションは次のとおりです。
1: 実行します。これは、文字列が画面の右側からはみ出しているため、開発者がメッセージを読むのに面倒なスクロールと読まなければならないため、悪いことです。
string s = "this is my really long string. this is my really long string. this is my really long string. this is my really long string. this is my really long string. this is my really long string. this is my really long string. this is my really long string. ";
2: @+改行。これはコードでは見栄えがしますが、文字列に改行が入ります。さらに、コードで見栄えを良くしたい場合は、改行を取得するだけでなく、文字列の各行の先頭に厄介なスペースも取得します.
string s = @"this is my really long string. this is my long string.
this line will be indented way too much in the UI.
This line looks silly in code. All of them suffer from newlines in the UI.";
3:"" + ...
これは問題なく動作しますが、入力するのが非常にイライラします。半行分のテキストをどこかに追加する必要がある場合は、あらゆる種類の + を更新し、テキストをあちこちに移動する必要があります。
string s = "this is my really long string. this is my long string. " +
"this will actually show up properly in the UI and looks " +
"pretty good in the editor, but is just a pain to type out " +
"and maintain";
4: string.format or string.concat
. 基本的には上記と同じですが、プラス記号はありません。同じ利点と欠点があります。
これをうまく行う方法は本当にありませんか?