Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:57:17+00:00 2026-06-17T05:57:17+00:00

I am writing a UI application which accept an input from the user –

  • 0

I am writing a UI application which accept an input from the user –

up to 50,000 entries which he pastes to a Textbox, which I need to convert to List<Uint32> (Distinct)

In the process, I display the Distict list (the output) in the ‘Textbox’.

I am splitting the text and converting it to a Distinct list of Uint32
Then I convert the list to array.

private List<UInt32> ConvertTextToList(string TextBoxText)
{
string[] TextBoxSplitted = TextBoxText.Split(new string[] { Environment.NewLine},StringSplitOptions.RemoveEmptyEntries); //Fast
            var TextBoxSplittedAsList = TextBoxSplitted.ToList<string>(); //Fast
            List<UInt32> lp = TextBoxSplittedAsList.ConvertAll(new Converter<string, UInt32>(element => Convert.ToUInt32(element))); //Fast
            List<UInt32> uintList = lp.Distinct<UInt32>().ToList<UInt32>(); //Fast
            UInt32[] uintListArray = uintList.ToArray(); //Fast

            //Slow part (measured 15 sec on core2duo 2.53GHz)
            StringBuilder builder = new StringBuilder();
            Array.ForEach(uintListArray, x => builder.Append(x));                
            //Done slow part

            SomeTextBox.text = builder.ToString();

            return uintList;
}

First I tried with – ListOfHeliostatsText.Text = string.Join(",", uintListArray);

Which was slower (about 25% slower than using StringBuilder)

I feel my function designed wrong, two many conversions.

Is there anyway to improve the performance of this function ?

EDIT:
My bad,
The slow part is the ListOfHeliostatsText.Text = builder.ToString();

I will continue reading the answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:57:18+00:00Added an answer on June 17, 2026 at 5:57 am

    You have measured incorrectly. The slow part is not:

    StringBuilder builder = new StringBuilder();
    Array.ForEach(uintListArray, x => builder.Append(x)); 
    

    The slow part is:

    SomeTextBox.Text = builder.ToString();
    

    The problem is that you are feeding one huge line to the text box. If you put each string in its own line….

    Array.ForEach(uintListArray, x => builder.AppendLine(x.ToString()));
    

    …you’ll observe roughly a 50-fold speedup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I'm writing a Java Command-line application which accept parameter from user by readLine.
I'm writing web application where I need to push data from server to the
I'm writing an application that needs to create a special user account hidden from
I'm writing an application which works with excel files. I need a feature to
I am writing an iPhone application which requires the user to enter their mobile
I need to build an application which can receive data from over a network
I am writing an C++ Application which reads several voltages from a device. I
So, I'm writting a CLI application in C++ which will accept a bunch of
I'm writing an application which will involve interaction with the database. The application will
I'm writing an application which have to take a picture and send it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.