compare two ip with C#

后端 未结 6 1303
夕颜
夕颜 2021-01-08 01:31

How I can compare two IP address?

string ip1 = \"123.123.123.123\";
string ip2 = \"124.124.124.124\";

I need some like this:



        
6条回答
  •  一向
    一向 (楼主)
    2021-01-08 01:51

    IPAddress addr1 = IPAddress.Parse(ip1);
    IPAddress addr2 = IPAddress.Parse(ip2);
    
    return (addr1.Equals(addr2));
    

提交回复
热议问题