如何使用IEnumerable(Of T) 接口? RRS feed

  • 问题

  • 有两个表,具有某些相同的列,想要调用同一方法分别逐行进行操作,如下:

      Dim q1 = From dr In dt1  Select dr.col1, dr.col2, dr.col3

      Dim q2 = From dr In dt2  Select dr.col1, dr.col2, dr.col3


     Private Sub qqq(ByVal q AS ......) 

      For Each dr In q


    End Sub



    2013年7月6日 0:22


  • 建议你应该定义一个类作为容器包含这些字段,然后可以指定参数:

    Public Class MyClass
       Public Property Col1 As String = Nothing
       Public Property Col2 As String = Nothing
       Public Property Col3 As String = Nothing
    End Class
    Private Sub qqq(ByVal q As IEnumerable(Of MyClass)
    End Sub
    Dim q1 = From …… Select New MyClass With{.Col1=xxx,.Col2=yyy……}

    If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer

    Help by clicking:
    Click here to donate your rice to the poor
    Click to Donate
    Click to feed Dogs & Cats

    Found any spamming-senders? Please report at: Spam Report

    2013年7月6日 2:01