http://msdn.microsoft.com/zh-cn/library/dd783876.aspx
这个示例,我测试的时候为什么是错误的?      string output = String.Join(" ", GetAlphabet(true).Where( letter => 
                      letter.CompareTo("M") >= 0));与“string.Join(string, string[])”最匹配的重载方法具有一些无效参数

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.Linq;public class Example
    {
       public static void Main()
       {
          string output = String.Join(" ", GetAlphabet(true).Where( letter => 
                          letter.CompareTo("M") >= 0));
          Console.WriteLine(output);  
       }   private static List<string> GetAlphabet(bool upper)
       {
          List<string> alphabet = new List<string>();
          int charValue = upper ? 65 : 97;
          for (int ctr = 0; ctr <= 25; ctr++)
             alphabet.Add(Convert.ToChar(charValue + ctr).ToString());
          return alphabet; 
       }
    }
    // The example displays the following output:
    //      M N O P Q R S T U V W X Y Z我运行是错误的,为什么
    与“string.Join(string, string[])”最匹配的重载方法具有一些无效参数
      

  2.   

    GetAlphabet(true).Where( letter =>  
      letter.CompareTo("M") >= 0)
    这个是什么类型,要转为string[],否则不匹配
      

  3.   


        string output = String.Join(" ", GetAlphabet(true).Where(letter => letter.CompareTo("M") >= 0).ToArray());