Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Problem with showing strings on textbox on forms, showing one at a time (async wait) C#

I got stuck on a problem for so long and I really need your help!
So my project is using Twitter API and my goal is to show specific tweets on win forms.
after using the API I’m getting an Array and each object inside the array contain a text section with the string that represents the tweet as you can see here:
enter image description here

So I wrote :
textBox2.Text = tweets5[0].Text;
and each time the textbox shows one tweet at a time and I want it to show
all of them together on that textbox.

I tried to use for but the signature of the method is :
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried to print the length, tried foreach, tried while and
nothing seems to work…

Thanks a lot for your time!

>Solution :

There are many ways you can accomplish this. I’ll suggest one:

You could loop through your array and append the text each time to a StringBuilder.

StringBuilder AllText = new StringBuilder(tweets5[0].Text + Environment.NewLine);

for (int i = 1; i < tweets5.Count; i++)
{
    AllText.Append(tweets5[i].Text + Environment.NewLine);
}

TextBox.Text = AllText.ToString();
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading