vb.net Dictionary(Of String,Object)enum.getname()(vb.net Dictionary(Of String, Object) enum.getname())
我正在做一个VB.Net WinForm应用程序。 这是C#的迁移。
在C#中,我有一个像这样定义的变量。
private static Dictionary<string, ExportFormatType> dicExtensiones = new Dictionary<string, ExportFormatType> { {".pdf", ExportFormatType.PortableDocFormat}, {".doc", ExportFormatType.WordForWindows}, {".xls", ExportFormatType.Excel}, {".rtf", ExportFormatType.RichText}, {".html", ExportFormatType.HTML40}, {".txt", ExportFormatType.Text} };我迁移到了这个..
Private Shared dicExtensiones = New Dictionary(Of String, ExportFormatType) From {{".pdf", ExportFormatType.PortableDocFormat}, {".doc", ExportFormatType.WordForWindows}, {".xls", ExportFormatType.Excel}, {".rtf", ExportFormatType.RichText}, {".html", ExportFormatType.HTML40}, {".txt", ExportFormatType.Text}}现在我需要遍历所有ítems并获得每个值...
在C#中是这样的。
List<String> lista = new List<string>(); foreach (var item in dicExtensiones) { lista.Add(Enum.GetName(typeof(ExportFormatType), item.Value)); lista.Add("*" + item.Key); }我遇到的问题是我确实知道如何迁移
Enum.GetName(typeof(ExportFormatType), item.Value);到VB.Net,因为VB.Net中不存在Enum.GetName
我该怎么做?
I am doing an VB.Net WinForm Application. It is a migration of C#.
In C# I have a variable defined like this.
private static Dictionary<string, ExportFormatType> dicExtensiones = new Dictionary<string, ExportFormatType> { {".pdf", ExportFormatType.PortableDocFormat}, {".doc", ExportFormatType.WordForWindows}, {".xls", ExportFormatType.Excel}, {".rtf", ExportFormatType.RichText}, {".html", ExportFormatType.HTML40}, {".txt", ExportFormatType.Text} };And i migrated to this..
Private Shared dicExtensiones = New Dictionary(Of String, ExportFormatType) From {{".pdf", ExportFormatType.PortableDocFormat}, {".doc", ExportFormatType.WordForWindows}, {".xls", ExportFormatType.Excel}, {".rtf", ExportFormatType.RichText}, {".html", ExportFormatType.HTML40}, {".txt", ExportFormatType.Text}}Now I need to Loop through all ítems and get each value...
In C# is like this.
List<String> lista = new List<string>(); foreach (var item in dicExtensiones) { lista.Add(Enum.GetName(typeof(ExportFormatType), item.Value)); lista.Add("*" + item.Key); }The problem i have is that I do know how to migrate
Enum.GetName(typeof(ExportFormatType), item.Value);to VB.Net, because Enum.GetName does not exists in VB.Net
How can I do it?
最满意答案
它可以像下面的VB一样
Dim lista As List(Of [String]) = New List(Of String)() For Each item As var In dicExtensiones lista.Add([Enum].GetName(GetType(ExportFormatType), item.Value)) lista.Add("*" + item.Key) Nextit can be like below in VB
Dim lista As List(Of [String]) = New List(Of String)() For Each item As var In dicExtensiones lista.Add([Enum].GetName(GetType(ExportFormatType), item.Value)) lista.Add("*" + item.Key) Next
更多推荐
发布评论