C # 's NetworkInterface ipinterfaceproperties

Source: Internet
Author: User

System.Net.NetworkInformation under the

The 1:networkinterface class, which provides configuration and statistics for the network adapter.

It detects how many NICs are configured on the computer, which network connections are available, and gets the MAC address and speed of the NIC.

This class encapsulates data for a network interface (also known as an adapter) on the local computer. you do not need to create an instance of this class; The Getallnetworkinterfaces method returns an array that contains an instance of this class for each network interface on the local computer.

getallnetworkinterfaces method returns an array that contains one Instance of this class for each network interface on the local computer. " > 2: ipinterfaceproperties class Provides information about network interfaces that support Internet Protocol version 4 (IPV4) or Internet Protocol version 6 (IPV6).

This class can be used to access configuration and address information for network interfaces that support IPV4 or IPV6. getipproperties method. " > Do not create instances of this class that will be returned by the Getipproperties method.

To access IPv4 specific properties, use the object returned by the Getipv4properties method. to access IPv6 specific properties, use the object returned by the Getipv6properties method

1     voidStart () {2         //Network card information class3networkinterface[] Adapters =networkinterface.getallnetworkinterfaces ();4         foreach(NetworkInterface ADAPinchadapters)5         {6Debug.Log ("cardname::"+ ADAP. Name +"/speed::"+ ADAP. Speed +"/mac::"+bitconverter.tostring (ADAP. Getphysicaladdress (). Getaddressbytes ()));7Ipinterfaceproperties ipproperties =ADAP. Getipproperties ();8Gatewayipaddressinformationcollection gateways =ipproperties.gatewayaddresses;9             foreach(varTmpinchgateways)Ten             { OneDebug.Log ("gateway>>>"+tmp. Address); A             } -Ipaddresscollection dnsaddress =ipproperties.dnsaddresses; -             foreach(IPAddress tmpinchdnsaddress) the             { -Debug.Log ("dns>>>"+bitconverter.tostring (tmp. Getaddressbytes ())); -             } -         } +}

Output

Networkinterface>>> https://msdn.microsoft.com/zh-cn/library/ System.net.networkinformation.networkinterface%28v=vs.110%29.aspx

ipinterfaceproperties>>> https://msdn.microsoft.com/zh-cn/library/ System.net.networkinformation.ipinterfaceproperties%28v=vs.110%29.aspx

C # 's NetworkInterface ipinterfaceproperties

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.