splitting a long string
-
Hi All Do you know if it is possible to split a string in several lines in C# In C++ I can write
std::cout << "this is a very "
"very very very "
"very very very "
"long string split into 4 lines that will be printed in one";Do you know if I can do the same in C#? Thanks MN
-
Hi All Do you know if it is possible to split a string in several lines in C# In C++ I can write
std::cout << "this is a very "
"very very very "
"very very very "
"long string split into 4 lines that will be printed in one";Do you know if I can do the same in C#? Thanks MN
Yes:
Console.WriteLine( "this is a very " +
"very very very " +
"very very very " +
"long string split into 4 lines that will be printed in one");Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
-
Hi All Do you know if it is possible to split a string in several lines in C# In C++ I can write
std::cout << "this is a very "
"very very very "
"very very very "
"long string split into 4 lines that will be printed in one";Do you know if I can do the same in C#? Thanks MN
could try this
Console.WriteLine(@"this is a very
very very very
very very very
long string split into 4 lines that will be printed in one") -
could try this
Console.WriteLine(@"this is a very
very very very
very very very
long string split into 4 lines that will be printed in one") -
Yes:
Console.WriteLine( "this is a very " +
"very very very " +
"very very very " +
"long string split into 4 lines that will be printed in one");Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Hi Thanks! Is there any other way without the + char at the end? For each + I think that C# due to how the String are will create in memory a new object that is the result of "String1" + "String2". I need just some facility so that compiler will recognize that it must print on the same line. This was the purpose of my questions even if I didn't make it explicit
-
Hi Thanks! Is there any other way without the + char at the end? For each + I think that C# due to how the String are will create in memory a new object that is the result of "String1" + "String2". I need just some facility so that compiler will recognize that it must print on the same line. This was the purpose of my questions even if I didn't make it explicit
Hi, the C# compiler understands concatenation of string literals and executes them once, while compiling. It all results in one big string literal before your code actually gets executed, just the way you intended it. You could check with Reflector[^]. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
modified on Friday, February 26, 2010 12:57 PM
-
Thanks, but I need the string on the same line not on different lines. When I have to print that I will see the new line I guess.
manustone wrote:
I guess
X| Read the documentation; perform an experiment; don't guess.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.