【发布时间】:2009-09-11 06:21:34
【问题描述】:
我看到了一些关于在 C# 中将项目添加到 IEnumerable 的先前已回答的问题,但在尝试在 VB.NET 中实现建议的解决方案时遇到了困难。
Option Strict On
Dim customers as IEnumerable(Of Customer)
' Return customers from a LINQ query (not shown)
customers = customers.Concat(New Customer with {.Name = "John Smith"})
上面的代码给出了错误:
Option Strict On 不允许从 Customer 到 IEnumerable(Of Customer) 的隐式转换
VS2008 然后建议使用 CType,但这会导致我运行时崩溃。我错过了什么?
【问题讨论】:
标签: vb.net