Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从Java.Net.NetworkInterface检索信息_C#_Android_Xamarin_Mono - Fatal编程技术网

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

C# 如何从Java.Net.NetworkInterface检索信息,c#,android,xamarin,mono,C#,Android,Xamarin,Mono,我用这种方法试图获取设备的本地ip地址 Java.Util.IEnumeration networkInterfaces = Java.Net.NetworkInterface.NetworkInterfaces; while (networkInterfaces.HasMoreElements) { Java.Net.

我用这种方法试图获取设备的本地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][/code>

为什么不使用类的各个属性,而不是尝试正则表达式ToString()的输出@Jason,因为除了
[wlan0]
之外,其他接口在while循环中应该获得ip,但是如果我知道如何首先获得ip,我将能够获得所有ip。。。