怎么样才能获得本机ip??

解决方案 »

  1.   

    终于找到拉
    using System.Net
    Dns.GetHostName();//获取本地计算机名
    string str_ServerIP = Dns.Resolve( Dns.GetHostName() ).AddressList[0].ToString();//得到本地的IP地址
      

  2.   

    Sample code as follows:
    IPHostEntry hostInfo = Dns.GetHostByName( Dns.GetHostName() );// Get the IP address list that resolves to the host names contained in the 
    // Alias property.
    IPAddress[] address = hostInfo.AddressList;foreach( IPAddress ip in address )
         Debug.WriteLine( ip.ToString() );
      

  3.   

    这些在.net的帮助里面都能找到,里面有很多例子