class Program
    {
        static void Main(string[] args)
        {
            String a = "2008-08-08";
            String b = a.Split("-");
            Console.WriteLine("{0}年{1}月{2}日", b[0], b[1], b[2]);
            Console.ReadKey();
            
        }
       
        }错误 1 与“string.Split(params char[])”最匹配的重载方法具有一些无效参数 C:\Users\LXL\Documents\Visual Studio 2005\Projects\ConsoleApplication4\ConsoleApplication4\Program.cs 12 24 ConsoleApplication4

解决方案 »

  1.   

    a.Split("-");
    =》
    a.Split('-');
      

  2.   

     String[] b = a.Split("-");
      

  3.   

     String[] b = a.Split('-');
      

  4.   

    class Program
      {
      static void Main(string[] args)
      {
      String a = "2008-08-08";
      Console.WriteLine(DateTime.Parse(a).ToString("yyyy年MM月dd日"));
      Console.ReadKey();
        
      }
        
      }
      

  5.   

    String b = a.Split("-");
    split("-")换成split('-')因为-是一个字符,不是字符串,如果有多个字符则用双引号,者利用单引号就行了!
      

  6.   

    改了之后,又出现这样的报错
    错误 1 无法将类型“string[]”隐式转换为“string” C:\Users\LXL\Documents\Visual Studio 2005\Projects\ConsoleApplication4\ConsoleApplication4\Program.cs 12 24 ConsoleApplication4
      

  7.   

            string a = "2008-08-08";
            string[] b = a.Split('-');
            Console.WriteLine(string.Format("{0}年{1}月{2}日", b[0], b[1], b[2]));已测试通过。
      

  8.   


    //定义变量  string 要小写的,writeline里的大括号 要英文的
                string a = "2008-08-08";
                string[] b = a.Split('-');
                Console.WriteLine("{0}年{1}月{2}日", b[0], b[1], b[2]);
                Console.ReadKey();
      

  9.   

    很好,Console.WriteLine(string.Format("{0}年{1}月{2}日", b[0], b[1], b[2]));
    这句为什么要这样写?
      

  10.   


    String a = "2008-08-08";
      String[] b = a.Split('-');
      

  11.   

    楼上都给出来正确解释了,我就不多说啦。
    建议楼主敲代码的时候多多利用工具的智能提示,每写一段代码就Alt + B + U一下,养成良好的习惯。
    另外,除了引号内的字符串,其他的都不能用中文格式的,尤其是空格,括号要多注意。
    至于string.Format()这个方法,建议楼主去google一下,遇到了问题先google是个好习惯!
      

  12.   

    上面的正解。
    楼主你这个变量b都不是数组,你还当数组用了。
     -》Console.WriteLine("{0}年{1}月{2}日", b[0], b[1], b[2]);
      

  13.   

    String b = a.Split(new char[]{'-'});
    结贴吧
      

  14.   

    String[] b = a.Split(new char[]{'-'});
    结贴吧
      

  15.   

    string a = "2008-08-08";
    string[] b = a.Split('-');
    Console.WriteLine(string.Format("{0}年{1}月{2}日", b[0], b[1], b[2]));
      

  16.   

    vs2010通过测试
     class Program
        {
            static void Main(string[] args)
            {
                string a = "2008-09-20";
                string[] b = a.Split('-');
                Console.WriteLine("{0}年{1}月{2}日", b[0], b[1], b[2]);
                Console.ReadKey();
            }
        }