Question on string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,

I have a string of around 150 characters.

string test = "asjhdkashdkjahsdjkhaskjdhaskjdhasjdhasd........."; //(upto
150 characters)

I want to split the above string into multiple lines in IDE while declaring
it so that it is more readable. How can I do that?

I do not want to concatenate using "+" nor do I want to use stringbuilder
object. I tried using @. If I use @ followed by the string, compiler is
inserting special characters like \t,\n. I think that I can StringBuilder
object but are there any other alternatives?

My goal is to be able to declare string like this without using "+" or
stringbuilder spread accross in multiple lines in IDE.

string test = "asjhdajkshdjkashdajksdhajskdhasd
sdfsjkdhfkjsdhfsjkdhfskjdfhskdjfhsd
sdfhsdjkfhsjdkfhsdjkfhsdjkfhsdkjfhs";

I hope I made sense as to what I want to achieve....

Thank you.
 
Diffident,

How about turning on word wrapping in the IDE?

Tools - Options

Language node of your choice: Check the "Word wrap" check box.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
use the "+" for readability, as the compiler will optimize it out.

-- bruce (sqlwork.com)
 
Bruce,

Can you please explain me how compiler would be able to optimize "+".

Why I did not want to use string concatenation was that I wanted it to be a
single string object and hence less memory would be used. But if I use "+"
does not that consume more memory due to string's inherent property of
immutability and hence heavy cost of concatenations?

Please correct me if I am wrong...
 
Back
Top