C # obtain all IP addresses of the Local Machine (including LAN and Internet IP addresses of the local machine)

Source: Internet
Author: User
Using  System. net;  Namespace  Jihua. cnblogs. com {  Class  Nethelper {  ///   <Summary>          ///  Obtain all local IP addresses, including lan ip addresses and local Internet IP addresses (if any)  ///   </Summary>          ///   <Returns>  192.168.1.10 | 220.181.112.143 </Returns>          Public   Static   String  Getallip () {IPaddress [] IP = DNS. gethostaddresses (DNS. gethostname ());  Int M_count = IP. length;  String M_allip = String  . Empty;  For ( Int I =0 ; I <m_count; I ++ ){  If (I> 0  ) M_allip = M_allip + "  |  "  ; M_allip + = IP [I]. tostring ();}  Return  M_allip ;}}} 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.