Exemple #1
0
 public static int getNum(int[] arrNum, int tmp, int minValue, int maxValue, Random ra)
 {
     for (int i = 0; i <= arrNum.Length - 1; i++)
     {
         if (arrNum[i] == tmp)
         {
             tmp = ra.Next(minValue, maxValue);
             NumberCode.getNum(arrNum, tmp, minValue, maxValue, ra);
         }
     }
     return(tmp);
 }
Exemple #2
0
        public static string[] getRandomNumNoRepeat(int num, int minValue, int maxValue)
        {
            Random ra = new Random((int)DateTime.Now.Ticks);

            int[]    arrNum   = new int[num];
            string[] strArray = new string[num];
            for (int index = 0; index <= num - 1; ++index)
            {
                int tmp  = ra.Next(minValue, maxValue);
                int num1 = NumberCode.getNum(arrNum, tmp, minValue, maxValue, ra);
                arrNum[index]   = num1;
                strArray[index] = num1 >= 10 ? string.Concat((object)num1) : "0" + (object)num1;
            }
            return(strArray);
        }
Exemple #3
0
        public static string[] getRandomNumNoRepeat(int num, int minValue, int maxValue)
        {
            Random random = new Random((int)DateTime.Now.Ticks);

            int[]    array  = new int[num];
            string[] array2 = new string[num];
            for (int i = 0; i <= num - 1; i++)
            {
                int tmp  = random.Next(minValue, maxValue);
                int num2 = NumberCode.getNum(array, tmp, minValue, maxValue, random);
                array[i] = num2;
                if (num2 < 10)
                {
                    array2[i] = "0" + num2;
                }
                else
                {
                    array2[i] = string.Concat(num2);
                }
            }
            return(array2);
        }
Exemple #4
0
        public static string CreateCodePk10(int codeLength)
        {
            string[] strArray = new string[10]
            {
                "01",
                "02",
                "03",
                "04",
                "05",
                "06",
                "07",
                "08",
                "09",
                "10"
            };
            List <string> myList = new List <string>();

            for (int index = 0; index < strArray.Length; ++index)
            {
                myList.Add(strArray[index]);
            }
            return(string.Join(",", NumberCode.ListRandom(myList).ToArray()));
        }
Exemple #5
0
        public static string CreateCodePk10(int codeLength)
        {
            string[] array = new string[]
            {
                "01",
                "02",
                "03",
                "04",
                "05",
                "06",
                "07",
                "08",
                "09",
                "10"
            };
            List <string> list = new List <string>();

            for (int i = 0; i < array.Length; i++)
            {
                list.Add(array[i]);
            }
            list = NumberCode.ListRandom(list);
            return(string.Join(",", list.ToArray()));
        }
Exemple #6
0
 public static string[] CreateCode20()
 {
     string[] randomNumNoRepeat = NumberCode.getRandomNumNoRepeat(20, 1, 99);
     NumberCode.SortByCount(randomNumNoRepeat);
     return(randomNumNoRepeat);
 }