VB等效代码到C#;字符串列表

时间:2016-02-01 09:54:25

标签: c# vb.net string list integer

C#中以下代码的等效内容是什么?

Dim intValidChars As New List(Of Integer)(New Integer() { Asc("0"), Asc("1"), Asc("2"), Asc("3"), Asc("4"), Asc("5"), Asc("6"), Asc("7"), Asc("8"), Asc("9"), _
                                                              Asc("A"), Asc("B"), Asc("C"), Asc("D"), Asc("E"), Asc("F"), Asc("G"), Asc("H"), Asc("I"), Asc("J")})    

提前致谢。

1 个答案:

答案 0 :(得分:2)

  • 将VB DLL引用添加到项目(import Microsoft.VisualBasic;)。

试试这段代码:

List<int> intValidChars = new List<int>(new int[] {
    Strings.Asc("0"),
    Strings.Asc("1"),
    Strings.Asc("2"),
    Strings.Asc("3"),
    Strings.Asc("4"),
    Strings.Asc("5"),
    Strings.Asc("6"),
    Strings.Asc("7"),
    Strings.Asc("8"),
    Strings.Asc("9"),
    Strings.Asc("A"),
    Strings.Asc("B"),
    Strings.Asc("C"),
    Strings.Asc("D"),
    Strings.Asc("E"),
    Strings.Asc("F"),
    Strings.Asc("G"),
    Strings.Asc("H"),
    Strings.Asc("I"),
    Strings.Asc("J")
});