的string.join()在.NET 3.5

编程入门 行业动态 更新时间:2024-10-27 15:26:04
本文介绍了的string.join()在.NET 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I have a 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/ 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:

msdn.microsoft/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

本文发布于:2023-11-04 12:34:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557955.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:join   string   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!