如何从Java.Net.NetworkInterface检索信息

时间:2017-06-04 20:39:58

标签: c# android xamarin mono

我用这种方式尝试获取设备的本地IP地址

Java.Util.IEnumeration networkInterfaces = Java.Net.NetworkInterface.NetworkInterfaces;

                            while (networkInterfaces.HasMoreElements)
                            {
                                Java.Net.NetworkInterface netInterface =

                     (Java.Net.NetworkInterface)networkInterfaces.NextElement();
                                Console.WriteLine(netInterface.ToString());


                            }

此方法输出为:

[lo][1][/::1%1%1][/127.0.0.1]

[dummy0][2]

[sit0][3]

[ip6tnl0][4]

[wlan0][5][/fe80::8e77:12ff:fe5a:6052%wlan0%5][/192.168.100.135]

[ppp0][6][/10.0.0.1]

如何使用正则表达式仅匹配以[wlan0]开头的字符串并仅从组中获取C#中的ipv4地址?

[wlan0][28][/fe80::244:55ff:fe64:1619%wlan0%28][/192.168.88.43]

0 个答案:

没有答案