本帖最后由 carldlee 于 2011-09-06 16:34:39 编辑

解决方案 »

  1.   

    最简单的方式 string []strs= str.Split('\n');然后找最大的
      

  2.   

    string[] str = strA.Split('\n');
    然后每个str[i].Length 去判断吧是不是这样?
      

  3.   

    strA = "I’m far from perfect, \n but I know \n that I am still deservingthe when that someone is coming\n";string[] test=strA.Splt("\n");
    forearch(string s in test)
    {
    自己解决吧
    }
      

  4.   

                string strA = "I'm far form perfect, \n but I know \n that I am still deserving the when that someone is coming\n";
                string[] strArray = strA.Split('\n');
                int maxLength = 0;
                foreach (string str in strArray)
                {
                    if (maxLength < str.Length)
                    {
                        maxLength = str.Length;
                    }
                }            Console.WriteLine("The max length of strings is " + maxLength);
      

  5.   

    strA.Split('\n').Max(s => s.Length)
      

  6.   

    string myStr = "I'm far form perfect, \n but I know \n that I am still deserving the when that someone is coming\n";
                string[] array= strA.Split('\n');
                int maxLength = 0;
                foreach (string str in array)
                {
                    if (maxLength < str.Length)
                    {
                        maxLength = str.Length;
                    }
                }            Console.WriteLine("The max length of strings is " + maxLength);
      

  7.   

    int maxLength = strA.Splt("\n").Max(str => str.Length);
      

  8.   

    上面写成VB里的双引号了
    C# 
    int maxLength = strA.Splt('\n').Max(str => str.Length);