这是我如何检查我的字典occurences
是否已经包含一个键和一个值并为其分配键和值......但我需要另一个值,所以如何使用对象在这里?在vb.net的字典中使用对象
Occurences.Add(xRows.Cells(4).Value.ToString(), Object)
不知怎的,像这样:
occurences(xRows.Cells(4).Value.ToString()) = Double.Parse(occurences(xRows.Cells(4).Value.ToString()).ToString()) + <"1st object value here">)
但是,这是我目前如何做到这一点,只有有一个键和一个值,但我需要像钥匙,它具有(值,值)的对象,类似的东西:
实际代码:
If (occurences.ContainsKey(xRows.Cells(4).Value.ToString())) Then
occurences(xRows.Cells(4).Value.ToString()) = Double.Parse(occurences(xRows.Cells(4).Value.ToString()).ToString()) + Double.Parse(xRows.Cells(7).Value.ToString())
Else
occurences.Add(xRows.Cells(4).Value.ToString(), Double.Parse(xRows.Cells(7).Value.ToString()))
End If
Next
然后,我有另一种插入代码,我需要使用对象的第二个值。
Using commm As New MySqlCommand()
With commm
.Parameters.Clear()
.Parameters.AddWithValue("@iBrnchCde", cmbBrnchCode.Text)
.Parameters.AddWithValue("@iFCode", pair.Key)
.Parameters.AddWithValue("@iDesc", <"2nd OBJECT VALUE HERE">)
.Parameters.AddWithValue("@iQty", pair.Value)
.CommandText = oInsertString
.Connection = _conn
.CommandType = CommandType.Text
End With
commm.ExecuteNonQuery()
End Using
问题没有意义。 –
@MitchWheat我在问如何在字典中使用对象,它的哪一部分没有意义? –