[英]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.