任何人都可以請幫我將此轉換爲vb.net轉換C#來vb.net
for each (DictionaryEntry<String, Int64> entry in characterCounter)
{
textBox1.Text += String.Format("char {0} occurs {1} times", entry.Key, entry.Value);
}
最自由/在線轉換器拋出錯誤的
任何人都可以請幫我將此轉換爲vb.net轉換C#來vb.net
for each (DictionaryEntry<String, Int64> entry in characterCounter)
{
textBox1.Text += String.Format("char {0} occurs {1} times", entry.Key, entry.Value);
}
最自由/在線轉換器拋出錯誤的
For Each entry As KeyValuePair(Of [String], Int64) In characterCounter
txtSummary.Text += String.Format("char {0} occurs {1} times", entry.Key, entry.Value)
Next
試一下:http://www.developerfusion.com/tools/convert/csharp-to-vb/
當然本網站假定您擁有有效的C#代碼,這不是您的情況。 C#中沒有這樣的運算符for each
。此外,DictionaryEntry類不是通用的。這裏是自動翻譯:
For Each entry As DictionaryEntry In characterCounter
textBox1.Text += [String].Format("char {0} occurs {1} times", entry.Key, entry.Value)
Next
For Each entry As DictionaryEntry In characterCounter
textBox1.Text += String.Format("char {0} occurs {1} times", entry.Key, entry.Value)
Next
錯誤:System.Collections.DictionaryEntry'沒有類型參數,因此不能有類型參數。 – Smith
@Smith你是嚴格的...在你的c#代碼中的另一個錯誤... – Jon
this> characterCounter <給出Error>類型'System.Collections.Generic.KeyValuePair(Of String,Long)'的值不能轉換爲' System.Collections.DictionaryEntry」。我聲明它是這樣的> Dim characterCounter As New Dictionary(Of [String],Int64)() – Smith
For Each entry As DictionaryEntry In characterCounter
textBox1.Text += String.Format("char {0} occurs {1} times", entry.Key, entry.Value)
Next
您也可以嘗試的C#轉換爲vb.net這裏這個在線工具:C# to VB
正如我所說的,它拋出一個錯誤,有你自己試過了嗎? – Smith
@史密斯,是的,我試過了,它工作。修復你的代碼之後,因爲正如我在我的回答中所說的,你在這裏顯示的是不是有效的C#代碼。 –
錯誤:System.Collections.DictionaryEntry'沒有類型參數,因此不能有類型參數。 – Smith