簡體   English   中英

如何修復數據集合中數據行的后期綁定,其中數據行變量在范圍內定義

[英]How to fix late binding for datarow in datacollection where datarow variable defined in range

我正在為我的公司將 VB 轉換為 C#.Net。 為了更容易地做到這一點,我有選項嚴格打開。 我正在嘗試解決以下代碼的后期綁定。 被編譯器視為 OBJECT。 我從來沒有以這種方式編寫過代碼(其他人的工作)。 這是代碼。

        Dim items As List(Of Contact) = ContactsTable.GetChanges.DataTableToList(Of Contact)
    'Dim row As DataRow = Nothing
    Dim modifiedRows As DataRowCollection = From row In ContactsTable.Rows
                       Where row.RowState = DataRowState.Modified Or row.RowState = DataRowState.Added

無法修改現有代碼。 下一個最佳選擇是使用“For each”循環對其進行重新編碼。

        Dim modifiedRows As DataRowCollection = Nothing
    For each row As DataRow In ContactsTable.Rows
        If row.RowState = DataRowState.Modified Or row.RowState = DataRowState.Added Then
            modifiedRows.Add(row)
        End If
    Next

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM