|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Question on stringI 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. -- Show quoteHide quoteSincerely, S. Justin Gengo, MCP Web Developer / Programmer www.aboutfortunate.com "Out of chaos comes order." Nietzsche "Diffident" <Diffid***@discussions.microsoft.com> wrote in message news:D2B9A188-596C-4B5F-80AA-FA8D6A7E08A1@microsoft.com... > 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. Works great!!
Did not know that I could use word wrap..... Show quoteHide quote "S. Justin Gengo [MCP]" wrote: > 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 > "Diffident" <Diffid***@discussions.microsoft.com> wrote in message > news:D2B9A188-596C-4B5F-80AA-FA8D6A7E08A1@microsoft.com... > > 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. > > > use the "+" for readability, as the compiler will optimize it out.
-- bruce (sqlwork.com) Show quoteHide quote "Diffident" <Diffid***@discussions.microsoft.com> wrote in message news:D2B9A188-596C-4B5F-80AA-FA8D6A7E08A1@microsoft.com... > 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. 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... Show quoteHide quote "Bruce Barker" wrote: > use the "+" for readability, as the compiler will optimize it out. > > -- bruce (sqlwork.com) > > > > "Diffident" <Diffid***@discussions.microsoft.com> wrote in message > news:D2B9A188-596C-4B5F-80AA-FA8D6A7E08A1@microsoft.com... > > 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. > > >
Other interesting topics
disabling html validation does not seem to stck
Parse-ing Strings Help on configuration file ??? Problems with ASP.NET 2.0 menu with Safari Error - System.Data.OleDb.OleDbException: Could not use ''; file already in use. - please help Application Performance Question Issues with multiple website development on Windows 2000 pro box Need Step by Step guide for setting up IIS 6 for ASP DataGrid Columns Spannig More Than One Column Referencing other web projects within Visual Studio 2005 |
|||||||||||||||||||||||