Domanda

So this question I am working on ask you to code a simple statement that was Base-16 followed by a newline character. And use Dim someValue As Integer = 346 to work with. Would this be correct [see code]? I am not sure if I understand decimal in VB all that well... Because looks like this "0000000000000346".

Module Module1

    Sub Main()
        Dim someValue As Integer = 346
        Console.WriteLine("{0:D16}" + vbNewLine, someValue)
    End Sub
End Module

Sorry if my question is not clear.

È stato utile?

Soluzione

The Convert.ToString() function has a useful overload which will generate a string representation of a number in some different bases:

Dim someValue As Integer = 346
Console.WriteLine(Convert.ToString(someValue, 16) & vbNewLine)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top