如何获得本机IP?急在线等,谢谢!

xiaoweihome 2004-11-21 11:14:22
c#如何获得本机IP?
...全文
173 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxyPioneer 2004-11-21
  • 打赏
  • 举报
回复
SystemInformations.HostName
Dns.HostName
可能我属性记不太清楚,你去查一下肯定有的
xiaoweihome 2004-11-21
  • 打赏
  • 举报
回复
Current是什么对象,编译器不认识。
cnhgj 2004-11-21
  • 打赏
  • 举报
回复
string hostname=Dns.GetHostName();
try
{
IPHostEntry hostip=Dns.Resolve(hostname);
IPAddress[] addrList=hostip.AddressList;
statusBar1.Text="本机IP地址:"+addrList[0];
}
catch(SocketException)
{
MessageBox.Show("IP address read error!");
}
lanbaibai 2004-11-21
  • 打赏
  • 举报
回复
string strIP = Current.Request.UserHostAddress;
luluso 2004-11-21
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3553/3553732.xml?temp=.4749414

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧