How to initialize byte array with one character and Encoding.ASCII.GetBytes in VB.NET

2 Answers

0 votes
Imports System.Text

Module Module1

    Sub Main()

        Dim array() As Byte = Encoding.ASCII.GetBytes(New String("W"c, 15))

        For Each ch As Byte In array
            Console.WriteLine(ch)
        Next

    End Sub

End Module


' run:
' 
' 87
' 87
' 87
' 87
' 87
' 87
' 87
' 87
' 87
' 87
' 87
' 87
' 87
' 87
' 87

 



answered Oct 2, 2018 by avibootz
0 votes
Imports System.Text

Module Module1

    Sub Main()

        Dim array() As Byte = Encoding.ASCII.GetBytes(New String("W"c, 15))

        For Each ch As Byte In array
            Console.WriteLine(Chr(ch))
        Next

    End Sub

End Module


' run:
' 
' W
' W
' W
' W
' W
' W
' W
' W
' W
' W
' W
' W
' W
' W
' W

 



answered Oct 2, 2018 by avibootz

Related questions

...