-1
我在Console WriteLine文本框中遇到问题。 我给这家将ConsoleWriteLine转换为文本框
Console.WriteLine(string.Format("IP: {0} Port: {1}", ip2, port));
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Format("IP: {0} Port: {1}", ip2, port));
textBox2.Text = sb.ToString();
码虽然消息框工作,
MessageBox.Show(Convert.ToString(ip2+":"+port));
这里是我的全部source codes。 我在这里做错了什么?
更新:
另一个solution使用的TextWriter控制台输出重定向到文本框。
你怎么可以在相同的代码位控制台应用程序和文本框(Windows/Web窗体?)? – Andrew
@Andrew,每个应用程序(独立于它的UI)都可以写入控制台。虽然它可能对普通用户不可见,只是在输出窗口中进行调试时或者从cmd.exe运行时 – RononDex
那么你每天都会学到新的东西:) – Andrew