Lambda 表达式在“Select Case”语句的第一个表达式中无效

更新:2007 年 11 月

不能在 Select Case 语句中使用测试表达式的 lambda 表达式。Lambda 表达式定义返回函数,Select Case 语句的测试表达式必须是基本数据类型。

下面的代码导致此错误:

' Select Case (Function(arg) arg Is Nothing)
    ' List of the cases.
' End Select

**错误 ID:**BC36635

更正此错误

  • 检查代码以确定其他条件结构(如 If...Then...Else 语句)对您是否有用。

  • 您可能故意调用该函数,如下面的代码所示:

    Dim num? As Integer
    Select Case ((Function(arg? As Integer) arg Is Nothing)(num))
        ' List of the cases
    End Select
    

请参见

概念

lambda 表达式

参考

If...Then...Else 语句 (Visual Basic)

Select...Case 语句 (Visual Basic)