簡體   English   中英

在 forms 的文本框中顯示字符串時出現問題,一次顯示一個(異步等待)C#

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

我在一個問題上卡了這么久,我真的需要你的幫助。 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此處:在此處輸入圖像描述

所以我寫道: textBox2.Text = tweets5[0].Text; 並且每次文本框一次顯示一條推文時,我希望它在該文本框上一起顯示所有推文。

我嘗試使用 for 但方法的簽名是:在此處輸入圖像描述

我嘗試打印長度,嘗試 foreach,嘗試 while,但似乎沒有任何效果......

非常感謝您的時間!

有很多方法可以做到這一點。 我會推薦一個:

您可以遍歷您的數組和 append 文本每次到 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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM