什么是VB.NET相当于这个C#代码?

Bob*_*Bob 5 vb.net c#-to-vb.net

VB.NET相当于这个C#代码?

    ctx.Load(site,
                x => x.Lists.Where(l => l.Title != null));
Run Code Online (Sandbox Code Playgroud)

我试过了

 ctx.Load(site, Function(x) x.Lists.Where(Function(l) l.Title IsNot Nothing))
Run Code Online (Sandbox Code Playgroud)

但这个错误 "The expression (Convert(l.Title) != null) is not supported."

思考

gar*_*rik 2

如果标题是字符串尝试使用 IsNullOrEmpty();

或者

Nullable(Of T).HasValue(如果标题可为 Null)

或者

Sub Main()

        Dim list As New List(Of A)

        Dim a1 As New A
        a1.Title = "sqws"
        Dim a2 As New A
        a2.Title = Nothing


        list.Add(a1)
        list.Add(a2)

        Dim q = From c In list Where c.Title IsNot Nothing

    End Sub



    Public Class A

        Dim t As String

        Public Property Title() As String
            Get
                Title = t
            End Get
            Set(ByVal value As String)
                t = value
            End Set
        End Property

    End Class
Run Code Online (Sandbox Code Playgroud)