C # how: define long line with line breaks?

Is there a way to define one long line with line breaks in the line definition code?

my line looks something like this:

string sql = "SELECT 
                     a.bg_user_56 AS Project, 
                     a.bg_user_60 AS SubSystem, 
                     a.BG_USER_81 AS AssignedToUserName, 
                     a.bg_responsible AS AssignedTo,  
              FROM mytable"
+3
source share
5 answers

Use a string string literal (starting with @):

string sql = @"SELECT 
                     a.bg_user_56 AS Project, 
                     a.bg_user_60 AS SubSystem, 
                     a.BG_USER_81 AS AssignedToUserName, 
                     a.bg_responsible AS AssignedTo,  
              FROM mytable"
+15
source
string sql = @"SELECT a.bg_user_56 AS Project,\r\na.bg_user_60 AS SubSystem,\r\na.BG_USER_81 AS AssignedToUserName,\r\na.bg_responsible AS AssignedTo,\r\nFROM mytable"
0
source

Like this:

string sql = @"MyNiceCleanStoredProc @Param";
0
source

The @ sign is great for this, but for SQL, I like to define my SQL as a project resource. This makes it easy to read, update, and open in Query Analyzer (or the T-Sql editor of your choice) and execute.

0
source

Use @ as

string s=@"Hello
           This is
           StackOverflow";
0
source

Source: https://habr.com/ru/post/1780486/


All Articles