c# - 如何将 ConsoleWrite 更改为标签文本
问题描述
好吧,我一直在使用我的 IP Get 和 console.write 函数,但是有一个问题,我不知道 Console.Write 做什么,我只需要该代码将转到标签文本,这意味着当 IP 获取时,它会转到Label.Text BTW,我使用Visual Studio c#。
private void metroLabel1_Click(object sender, EventArgs e)
{
String strHostName = string.Empty;
// Getting Ip address of local machine...
// First get the host name of local machine.
strHostName = Dns.GetHostName();
Console.WriteLine("Local Machine's Host Name: " + strHostName);
// Then using host name, get the IP address list..
IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
IPAddress[] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
Console.WriteLine("IP Address {0}: {1} ", i, addr[i].ToString());
//metroLabel1.Text = " >> " + "", i, addr[i].ToString());
// Console.WriteLine = metroLabel1.Text;
}
Console.ReadLine();
}
解决方案
尝试这个
metroLabel1.Text = inputString
推荐阅读
- ios - 隐藏标签栏后 UITabBarItem 字体更改
- python - 将数据框中列的值循环到 Python 中的函数
- php - 登录检查不起作用 Laravel-Middleware
- python - 改变用户输入
- python - 有没有办法自动更改 tkiner 窗口的大小以适应小部件?
- javascript - 动态流处理 Node.js
- javascript - 在 Javascript 中运行时(动态)在对象内部创建对象
- python - 导入 sympy 时出现 ImportError
- java - 使用 Java 方法时如何创建不同的延迟?
- java - 自定义 ArrayAdapter 过滤时不更新