如何通过某种循环生成以下规则的文件名列表?http://xxx.com/xxx_01.jpg
http://xxx.com/xxx_02.jpg
...
http://xxx.com/xxx_0a.jpg
http://xxx.com/xxx_0b.jpg
http://xxx.com/xxx_0c.jpg
http://xxx.com/xxx_0d.jpg
...
http://xxx.com/xxx_10.jpg
http://xxx.com/xxx_11.jpg
...
http://xxx.com/xxx_1a.jpg
http://xxx.com/xxx_1b.jpg
...
http://xxx.com/xxx_ff.jpg

解决方案 »

  1.   


    string[] Arr1 ={ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
                string[] Arr2 ={ "1", "2", "3", "4", "5", "6", "7", "8", "9" ,"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n" };
                string str = @"http://xxx.com/xxx_";
                string str1 = "";
                for (int i = 0; i < Arr1.Length; i++)
                {
                    for (int j = 0; j < Arr2.Length; j++)
                    {
                        str1 = str+Arr1[i].ToString() + Arr2[j].ToString() + ".jpg \n\r";
                        richTextBox1.Text += str1;
                    }
                }
    执行结果
    --
    http://xxx.com/xxx_01.jpg http://xxx.com/xxx_02.jpg http://xxx.com/xxx_03.jpg http://xxx.com/xxx_04.jpg http://xxx.com/xxx_05.jpg http://xxx.com/xxx_06.jpg http://xxx.com/xxx_07.jpg http://xxx.com/xxx_08.jpg http://xxx.com/xxx_09.jpg http://xxx.com/xxx_0a.jpg http://xxx.com/xxx_0b.jpg http://xxx.com/xxx_0c.jpg 
    .
    .
    .
    .
      

  2.   

    前面的固定
    后面的用2层循环即可可以参考3楼
    for (int i = 0; i < Arr1.Length; i++)
                {
                    for (int j = 0; j < Arr2.Length; j++)
                    {
                        str1 = str+Arr1[i].ToString() + Arr2[j].ToString() + ".jpg \n\r";
                        richTextBox1.Text += str1;
                    }
                }
      

  3.   

    如果同时需要像这样的:
    http://xxx.com/xxx_a3.jpg
    http://xxx.com/xxx_a4.jpg  
    且不出现00.jpg            string[] Arr2 ={ "0","1", "2", "3", "4", "5", "6", "7", "8", "9" ,"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n" };
                string str = @"http://xxx.com/xxx_";
                string str1 = "";
                for (int i = 0; i < Arr2.Length; i++)
                {
                    for (int j = 0; j < Arr2.Length; j++)
                    {
                        if (i == 0 && j == 0) continue; //不出现00.jpg
                        str1 = str + Arr2[i].ToString() + Arr2[j].ToString() + ".jpg \n\r";
                        richTextBox1.Text += str1;
                    }
                }
    如果不需要以上的
    http://xxx.com/xxx_a3.jpg
    http://xxx.com/xxx_a4.jpg              string[] Arr2 ={ "0","1", "2", "3", "4", "5", "6", "7", "8", "9" ,"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n" };
                string str = @"http://xxx.com/xxx_";
                string str1 = "";
                for (int i = 0; i < Arr2.Length; i++)
                {
                    for (int j = 0; j < Arr2.Length; j++)
                    {
                        if (i == 0 && j == 0) continue; //不出现00.jpg
                        if (i > 9 && j <10) continue;
                        str1 = str + Arr2[i].ToString() + Arr2[j].ToString() + ".jpg \n\r";
                        richTextBox1.Text += str1;
                    }
                }
      

  4.   


    string.Format("...", i);控制好 i 的显示格式即可.
      

  5.   

    private ArrayList shengchengming()
            {
                ArrayList al = new ArrayList();
                for (int i = 0; i < 16; i++)
                {
                    for (int j = 0; j < 16; j++)
                    {
                        al.Add("http://xxx.com/xxx_" + i.ToString("x") + j.ToString("x") + ".jpg");
                    }
                }
                return al;
            }
      

  6.   

    为什么不试试 i.ToString("X")哪??