C#VB.net翻译

时间:2015-06-11 11:43:40

标签: c# vb.net

我正在尝试从此线程Databinding an enum property to a ComboBox in WPF实现一个示例,但我需要将其转换为VB.net。这是Martin Liversage的答案。

关于这两行:

this.valueToNameMap = this.type.GetFields(BindingFlags.Static | BindingFlags.Public).ToDictionary(fi => fi.GetValue(null), GetDescription);
this.nameToValueMap = this.valueToNameMap.ToDictionary(kvp => kvp.Value, kvp => kvp.Key);

谢谢!

1 个答案:

答案 0 :(得分:1)

试试这个:

Me.valueToNameMap = Me.type.GetFields(BindingFlags.Static Or BindingFlags.Public).ToDictionary(Function(fi) fi.GetValue(Nothing), GetDescription)
Me.nameToValueMap = Me.valueToNameMap.ToDictionary(Function(kvp) kvp.Value, Function(kvp) kvp.Key)