I need to remove all the negative values from a list of integers.
Dim cells As List(Of Integer) = GridView1.GetSelectedRows().ToList()
cells
returns a list of rows getting from the devexpress grid view. But the filter/group option will return negative integers... How can I either remove those negative values from cells or prevent them from getting in to cells?
You can use this code :
Dim NumberOfElements As Integer = cells.Count - 1
Dim i As Integer = 0
While i <= NumberOfElements
If cells(i) < 0 Then
cells.RemoveAt(i)
NumberOfElements = NumberOfElements - 1
Else
i = i + 1
End If
End While
Dim postiveCells As List(Of Integer) = cells.[Where](Function(x) x > 0).ToList()
我想我找到了一种在vb.net中放置where子句的方法谢谢您的提示
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.