如果 Visual Studio 的 Intellisense 没有建议选项 –这是否意味着它并不总是受支持?

发布于 2024-12-13 07:38:25 字数 192 浏览 5 评论 0原文

我有一个 ObservableCollection,我正在使用 string[] s = myObservableCollection.ToArray(); 将其更改为数组,效果很好。然而,我注意到 VS 并没有在其自动完成功能中提供这一点。它仅提供 ToArray<> 。所以我想知道 - 这是否意味着它不受所有情况或平台等支持?

I have an ObservableCollection which I’m changing to an array using string[] s = myObservableCollection.ToArray();This works fine. I noticed, however, that VS does not offer that in its auto-complete. It only offers ToArray<> . So I wonder – does this mean it’s not supported in all cases or platforms etc. ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

森林散布 2024-12-20 07:38:25

如果编译通过,则支持。

智能感知并不完美,过度依赖它是一个错误。正如您所看到的,没有出现一个完全有效的选项。

在本例中,该方法可能是 LINQ 提供的 IEnumerable.ToArray() 扩展方法。

If it compiles, it is supported.

Intellisense is not perfect and relying on it too much is a mistake. As you have seen, a perfectly valid option didn't come up.

In this case, the method is probably the IEnumerable<T>.ToArray() extension method provided by LINQ.

花辞树 2024-12-20 07:38:25

对了,ObservableCollection<>没有 ToArray() 方法。您获得了 IntelliSense 提供的 Linq 扩展方法,毫无疑问您在源代码文件的顶部有一个 using System.Linq 指令。这确实要求您安装此软件的计算机至少具有 .NET 版本 3.5。这并不难实现。

Right, ObservableCollection<> doesn't have a ToArray() method. You get the Linq extension method offered by IntelliSense, you no doubt have a using System.Linq directive at the top of the source code file. Which does require that the machine you install this on has at least .NET version 3.5. That's not hard to come by.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文