-2

What is the equivalent of the following code in 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")})    

Thanks in advance.

Yousif H
  • 383
  • 1
  • 2
  • 10

1 Answers1

2
  • Add the VB DLL reference to the project (import Microsoft.VisualBasic;).

Try this code:

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")
});
rdn87
  • 739
  • 5
  • 18
  • To use the `String.Asc` you have to add the VB DLL reference to the project. You should mention that in answer. – Mahesh Feb 01 '16 at 10:03
  • yes, i edit my post @CoderofCode – rdn87 Feb 01 '16 at 10:05
  • Please don´t answer to this kind of questions since it is clearly a code writing/translating request. Do not encourage others to also ask those question! – Alex B. Feb 01 '16 at 10:11
  • Thank you, my problem was with adding the reference since it was giving me error on Strings.Asc :) – Yousif H Feb 01 '16 at 10:52