I am trying to get the contents of a StringBuilder to display in the WinForms text box, but the window never appears when I try to compile the program. This is my first venture in WinForms and C #, and I have been using the language for about a week and a half, so this is probably a simple fix that I just can't see.
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { StringBuilder builder = new StringBuilder(); Random rand = new Random(); int[] builderList = new int[10000]; for (int i = 0; i < 10000; i++) { builderList[i] = rand.Next(1, 20000); builder.Append(builderList[i].ToString() + " "); }
When I try to run the program and insert a breakpoint in this last line of code, I see that the program seems to just click this line continuously. Oddly enough, if I change this line to this:
textBox1.Text = "Hey, lol";
my program will start. I checked the debugger in Visual Studio and saw that the contents of "builderList" were updated to random numbers, and the "builder" looks like it correctly stores the values ββin "builderList" as a string, as I want, so I'm a little confused about that what is going on here. I would appreciate any help I can handle, as it seems like this should be relatively easy to fix, but I have still been at a dead end and I have not found anything useful in the MSDN documentation.
Many thanks!
source share