【发布时间】:2011-09-23 20:07:16
【问题描述】:
我有这个代码:
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(txtBoxIP.Text), MainForm.port);
例如,当我在 txtBoxIP (192.168.1.2) 中有一个 IP 时,它的效果很好。
但是如果我想放一个DNS呢?就像我说的(my.selfip.com)我得到了:
System.FormatException: An invalid IP address was specified.
at System.Net.IPAddress.InternalParse(String ipString, Boolean tryParse)
如何让它同时支持 IP 和 DNS?
【问题讨论】:
-
我删除了 parsing 标签,因为将主机名转换为 IP 称为“地址解析”而不是“解析”。