How to compare IP Address that is stored in an array of Ip[0] with remote Endpoint?? Please Help me.
相关问题
- Sorting 3 numbers without branching [closed]
- Multiple sockets for clients to connect to
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
I'm assuming you have retrieved the IP address via
If that's the case you can just compare via
Well you could just get them: ToString() and then compare them. Or you can iterate through the 4 numbers that an IPV4 ip Has, and compare them.
All the above variants will work but there's another option not mentioned here: Use the IpAddress GetAddressBytes method to obtain the address as bytes and compare them. This could be usefull if you need to make other processing (such as figuring if an Ip is in an IP class or something like this)..
You can use this class to extend IpAddress :
http://www.codeproject.com/Articles/26550/Extending-the-IPAddress-object-to-allow-relative-c
Simply compare each member of the struct.
Something like this should work ...