嗨,我想轉換此C#代碼到VB試圖讓從字典繼承的多值的字典 - C#到VB轉換
class MultiValueDictionary<TKey, TValue> : Dictionary<TKey, List<TValue>>
{
public void Add(TKey key, TValue value)
{
if(!ContainsKey(key))
Add(key, new List<TValue>());
this[key].Add(value);
}
}
結果看起來是這樣的:
Class MultiValueDictionary(Of TKey, TValue)
Inherits Dictionary(Of TKey, List(Of TValue))
Public Sub Add(key As TKey, value As TValue)
If Not ContainsKey(key) Then
Add(key, New List(Of TValue)())
End If
Me(key).Add(value)
End Sub
End Class
但它給上線一個錯誤:
Add(key, New List(Of TValue)())
典型值的數值e'System.Collections.Generic.List(Of TValue)'不能被 轉換爲'TValue'。
我不是很清楚TKey TValue符號,有人可以解釋這個錯誤告訴我什麼嗎?它應該讀什麼呢?
在此先感謝
不足['Lookup'](http://msdn.microsoft.com/zh-cn/library/bb460184.aspx)足夠嗎? – AgentFire
我認爲應該有一些區別是指VB.Net中的函數重載 –