Who know PHP, turn the PHP code into C# code on a few words, ~~thankyou

http://hi.baidu.com/xiyi2008/item/ebe792001cd6cc10cd34ea69

The inside of the PHP into the c# code for the master

Started by Jacqueline at November 25, 2016 - 7:55 AM

New to this wood knot paste rate for the master to help

Posted by Jacqueline at December 03, 2016 - 8:44 AM

Posted by Jacqueline at December 09, 2016 - 9:17 AM

I sprinkle, find people for money.

Posted by Ingrid at December 18, 2016 - 9:26 AM

Shrink randomly generated home IP address
A total of 1600 segment, only 10 of them is domestic network
The use of 2 PHP function
ip2long($ip)The IP to int
long2ip($int_ip)Put the int back to IP

Code:
$ip_long = array(
array('607649792', '608174079'), //36.56.0.0-36.63.255.255
array('1038614528', '1039007743'), //61.232.0.0-61.237.255.255
array('1783627776', '1784676351'), //106.80.0.0-106.95.255.255
array('2035023872', '2035154943'), //121.76.0.0-121.77.255.255
array('2078801920', '2079064063'), //123.232.0.0-123.235.255.255
array('-1950089216', '-1948778497'), //139.196.0.0-139.215.255.255
array('-1425539072', '-1425014785'), //171.8.0.0-171.15.255.255
array('-1236271104', '-1235419137'), //182.80.0.0-182.92.255.255
array('-770113536', '-768606209'), //210.25.0.0-210.47.255.255
array('-569376768', '-564133889'), //222.16.0.0-222.95.255.255
);
$rand_key = mt_rand(0, 9);
$ip= long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));

Posted by Jacqueline at December 22, 2016 - 10:08 AM

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static Dictionary<int, int> ips = new int[][]
            {
                Enumerable.Range(607649792, 608174079 - 607649792 + 1).ToArray(),
                Enumerable.Range(1038614528, 1039007743 - 1038614528 + 1).ToArray(),
                Enumerable.Range(1783627776, 1784676351 - 1783627776 + 1).ToArray(),
                Enumerable.Range(2035023872, 2035154943 - 2035023872 + 1).ToArray(),
                Enumerable.Range(2078801920, 2079064063 - 2078801920 + 1).ToArray(),
                Enumerable.Range(-1950089216, -1948778497 + 1950089216 + 1).ToArray(),
                Enumerable.Range(-1425539072, -1425014785 + 1425539072 + 1).ToArray(),
                Enumerable.Range(-1236271104, -1235419137 + 1236271104 + 1).ToArray(),
                Enumerable.Range(-770113536, -768606209 + 770113536 + 1).ToArray(),
                Enumerable.Range(-569376768, -564133889 + 569376768 + 1).ToArray()
            }.SelectMany(x => x).Select((x, i) => new { x, i }).ToDictionary(x => x.i, x => x.x);

        static string IpToString(int IP)
        {
            return string.Join(".", BitConverter.GetBytes(IP).Reverse().Select(x => ((int)x).ToString()));
        }

        static int GenIP()
        {
            return ips[new Random(Guid.NewGuid().GetHashCode()).Next(0, ips.Count)];
        }

        static void Main(string[] args)
        {
            for (int i = 0; i <10; i++)
                Console.WriteLine(IpToString(GenIP()));
        }
    }
}


222.31.192.2
222.61.179.167
210.35.44.234
61.232.181.244
61.237.216.109
222.45.176.12
61.235.187.162
106.93.230.103
139.206.173.148
210.37.146.231
Press any key to continue . . .

Posted by Adalheid at January 04, 2017 - 10:47 AM