的string.join()在.NET 3.5 [英] string.Join() in .net 3.5

查看:246
本文介绍了的string.join()在.NET 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2008的.NET 3.5的项目,我想要使用的 的string.join()(一,需要一个字符串和<$ C的这种超负荷 $ C>的IEnumerable< T> )和编译器似乎并不知道这个过载

I have a .net 3.5 project in vs2008 and I'm trying to use this overload of string.Join() (the one that takes a string and IEnumerable<T>) and the compiler does not seem to know about this overload.

这是我试过的代码

    var result = string.Join(" ", Foo());



其中,美孚()

    IEnumerable<string> Foo()
    {

        foreach(string s in new []{"1", "2", "3"} )
        {
            yield return s;
        }
    }



我得到

I get

> Error 2   Argument '2': cannot convert from
> 'System.Collections.Generic.IEnumerable<string>' to 'string[]'



当然,如果我用美孚()ToArray的()它的工作原理,但我不知道为什么会发生的IEnumerable<过载; T> 将无法工作。

Of course, if I use Foo().ToArray() it works but I'm wondering why the overload that takes IEnumerable<T> won't work.

MSDN经典视图中说,这是用VS2008兼容/ .NET 3.5

MSDN in classic view says it's compatible with vs2008/.net 3.5

(我做不到找到消息此页是特定于......非经典的看法,所以我想我会提出了一个屏幕帽。)

(I couldn't find the message "This page is specific to...." in non-classic views so I thought I'd put up a screen-cap.)

推荐答案

在底部的版本信息说不同的东西:

The version information at the bottom says something different:

请注意,你可以找到在文章底部的版本信息,而不管选择的看法(它可能只是看起来有些不同)。

Note that you can find that version information at the bottom of the article, regardless of the selected view (it might just look a little different).

在右上角的说明你已经发现是指所选资源版本,你可以在网址中找到,如

The note in the upper-right you have found is referring to the selected resource version you can find in the URL, such as in:

http://msdn.microsoft.com/en-us/library/dd783876 (VS.90) 的.aspx

(以粗体突出显示)。通常这种选择的框架版本,以及(因为这些被释放亦随VS),但显然也似乎是在这里的分类是错误的。

(highlighted in bold). Usually this selects the framework version as well (since those are released in tandem with VS), but apparently there seems to be a mistake in the classification here.

我想只是报告这是一个错误。

I'd just report it as a mistake.

这篇关于的string.join()在.NET 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆