[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Stringbuilder not working

Posted on 2006-10-23
1
Medium Priority
?
387 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 1400 total points
ID: 17790948
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

830 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