Solved

Stringbuilder not working

Posted on 2006-10-23
1
357 Views
Last Modified: 2010-04-16
I'm trying to use a stringbuilder to add lines together if the line is shorter than 305 characters. It reads the first line fine, reads the nextLine fine and captures those.

For some reason when I get to the string myString part it's blank..  How do I get my results into myString? Thanks!

                            policyLine = line;
                            nextLine = sr.ReadLine();
                            if(nextLine.Length < 305)
                            {
                                StringBuilder sb2 = new StringBuilder();
                                sb2.Append(policyLine);
                                sb2.Append(@"\");
                                sb2.Append(nextLine);
                                string myString = sb2.ToString();                          
                            }
0
Comment
Question by:boukaka
1 Comment
 
LVL 13

Accepted Solution

by:
devsolns earned 350 total points
Comment Utility
first you'll likely need to declare myString outside the if() scope if you want to use it outside that scope.  The use of StringBuilder looks fine.  Also for only 3 appends your gonna find that just concatenting strings is faster even though they are immutable.  I'd say almost 2x faster but you'll only notice the diff. in a lab.

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now