string.join的用法

rczjp 2012-05-09 03:42:50
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[])”最匹配的重载方法具有一些无效参数
...全文
131 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
花痴 2012-05-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
string output = String.Join(" ", GetAlphabet(true).Where(letter => letter.CompareTo("M") >= 0).ToArray());
[/Quote]
+1
porschev 2012-05-09
  • 打赏
  • 举报
回复

string output = String.Join(" ", GetAlphabet(true).Where(letter => letter.CompareTo("M") >= 0).ToArray());
bdmh 2012-05-09
  • 打赏
  • 举报
回复
GetAlphabet(true).Where( letter =>
letter.CompareTo("M") >= 0)
这个是什么类型,要转为string[],否则不匹配
rczjp 2012-05-09
  • 打赏
  • 举报
回复
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[])”最匹配的重载方法具有一些无效参数

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧