Hi,
I am working on a condition statement with a very long opening if statement and this requires me to keep scrolling right. How can I break onto a new line so my code is easier to read but without breaking the string?
e.g.
if (ThisUser.Company == "MyCompany" || ThisUser.Company == "MyCompany2" || ThisUser.Company == "MyCompany3" || ThisUser.Company == "MyCompany4" || ThisUser.Company == "MyCompany2")
{
Logo.ImageUrl = "../Images/Logo.png";
}
Thanks
M
Loading

VulpesRank #55 · 29.2K reputationPosted Aug 18, 2011, 1:58 AM EDT
However, string literals (i.e. strings enclosed in quotes) shouldn't be broken unless you precede them with '@'. For example:
string str = @"ab
Satish BhatRank #2,496 · 563 reputationPosted Aug 18, 2011, 1:58 AM EDT
But if you want to span a string into multiple lines you can either use " + " or string literal "@"
e.g.
string sqlString = "SELECT FIELD1, FIELD2 " +
"FROM TABLE_NAME " +
"WHERE FIELD3=100";
or
string sqlString = @"SELECT FIELD1, FIELD2
FROM TABLE_NAME
WHERE FIELD3=100";
Jiteendra SampathiraoRank #585 · 4.1K reputationPosted Aug 18, 2011, 2:05 AM EDT
really no need worry about it...no error will comes...
if (a == 10 || b == 20 ||
c == 30)
{
Console.WriteLine("it works");
}
but if you are using are declaring string value then you have to use '+" operator like this..
string testing = "I am working on a condition statement with a very long opening"
+ "if statement and this requires me to keep scrolling right."
+ "How can I break onto a new line so my code is easier to"
+ "read but without breaking the string";
i hope u got my point.....
Max Tenenbaum32 reputationPosted Aug 18, 2011, 2:07 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Aug 18, 2011, 9:36 PM EDT