Click here to Skip to main content
15,890,557 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionNumberGroupSeparator not working? Pin
Bernhard Hiller1-Apr-12 22:46
Bernhard Hiller1-Apr-12 22:46 
AnswerRe: NumberGroupSeparator not working? Pin
Eddy Vluggen1-Apr-12 23:37
professionalEddy Vluggen1-Apr-12 23:37 
GeneralRe: NumberGroupSeparator not working? Pin
Bernhard Hiller2-Apr-12 0:56
Bernhard Hiller2-Apr-12 0:56 
GeneralRe: NumberGroupSeparator not working? Pin
Eddy Vluggen2-Apr-12 1:05
professionalEddy Vluggen2-Apr-12 1:05 
GeneralRe: NumberGroupSeparator not working? Pin
VJ Reddy13-Apr-12 6:10
VJ Reddy13-Apr-12 6:10 
QuestionHow to select a feature using mouse click in DotSpatial Framework? Pin
Chandan Kumar Rath29-Mar-12 20:56
Chandan Kumar Rath29-Mar-12 20:56 
AnswerRe: How to select a feature using mouse click in DotSpatial Framework? Pin
Pete O'Hanlon29-Mar-12 21:14
mvePete O'Hanlon29-Mar-12 21:14 
QuestionHas StringBuilder gotten more efficient in VS2010? Pin
jesarg29-Mar-12 5:16
jesarg29-Mar-12 5:16 
I recently wrote some code to clean up user input by turning all multiple-space spaces into single-space spaces.

I tried several different approaches to optimize performance, and, interestingly enough, the stringbuilder is performing better than I remember from past versions. I can't seem to do better than the following no matter how hard I try to optimize.

C#
private StringBuilder builder = new StringBuilder();

public string RemoveExtraSpaces(string inputString)
{
    builder.Clear();
    int length = inputString.Length;
    if (length > 0)
    {
        builder.Append(inputString[0]);
        for (int loop1 = 1; loop1 < length; loop1++)
            if (inputString[loop1 - 1] != ' ' || inputString[loop1] != ' ')
                builder.Append(inputString[loop1]);
    }
    return builder.ToString();
}


Even for very short strings, this solution performs better than other solutions.

Edit: Also, for clarification, the RemoveExtraSpaces method is called many times in a row on a bunch of strings for performance testing.
AnswerRe: Has StringBuilder gotten more efficient in VS2010? Pin
so_soul29-Mar-12 5:45
so_soul29-Mar-12 5:45 
GeneralRe: Has StringBuilder gotten more efficient in VS2010? Pin
Not Active29-Mar-12 6:31
mentorNot Active29-Mar-12 6:31 
QuestionRe: Has StringBuilder gotten more efficient in VS2010? Pin
Stohn29-Mar-12 5:53
Stohn29-Mar-12 5:53 
AnswerRe: Has StringBuilder gotten more efficient in VS2010? Pin
jesarg29-Mar-12 7:15
jesarg29-Mar-12 7:15 
Questionhow to monitor ftp files by c#.net Pin
eng.rania27-Mar-12 4:06
eng.rania27-Mar-12 4:06 
AnswerRe: how to monitor ftp files by c#.net Pin
Pete O'Hanlon27-Mar-12 4:33
mvePete O'Hanlon27-Mar-12 4:33 
QuestionSIP webphone in Visual Studio 2008 and 2010 Pin
timothydary26-Mar-12 22:40
timothydary26-Mar-12 22:40 
RantImage.FromFile and exceptions PinPopular
Daniel Lo Nigro25-Mar-12 15:14
Daniel Lo Nigro25-Mar-12 15:14 
AnswerRe: Image.FromFile and exceptions Pin
Luc Pattyn25-Mar-12 15:58
sitebuilderLuc Pattyn25-Mar-12 15:58 
AnswerRe: Image.FromFile and exceptions Pin
Abhinav S25-Mar-12 16:51
Abhinav S25-Mar-12 16:51 
GeneralRe: Image.FromFile and exceptions Pin
Daniel Lo Nigro25-Mar-12 17:00
Daniel Lo Nigro25-Mar-12 17:00 
GeneralRe: Image.FromFile and exceptions Pin
Shameel27-Mar-12 5:08
professionalShameel27-Mar-12 5:08 
Question.net Pin
Abilove24723-Mar-12 21:45
Abilove24723-Mar-12 21:45 
AnswerRe: .net Pin
Abhinav S24-Mar-12 0:36
Abhinav S24-Mar-12 0:36 
QuestionFind text on vbnet webbrowser Pin
Member 873278715-Mar-12 23:51
Member 873278715-Mar-12 23:51 
QuestionCan I unsign an assembly and how... Pin
Jun Du15-Mar-12 14:14
Jun Du15-Mar-12 14:14 
AnswerRe: Can I unsign an assembly and how... Pin
Dave Kreskowiak15-Mar-12 15:24
mveDave Kreskowiak15-Mar-12 15:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.