none
How can I do Byte = ByteList ? RRS feed

  • Question

  • Code :

    Dim dataList As New List(Of Byte()) Private Sub chk(ByVal b() As Byte) For i = 0 To b.Length - 1 dataList.Add(Encoding.ASCII.GetBytes(b(i))) Next End Sub Public Sub Load() Try chk(buffer) ' Buffer another class in a byte()

    Dim byteArray(dataList.Count - 1) As Byte 'byteArray = dataList ? Dim newbyte() As Byte = csp.Decrypt(byteArray, False) Dim str as String = Encoding.ASCII.GetString(newByte) Catch ex As CryptographicException MsgBox(ex.ToString() + " " + ex.Message) End Try End Sub


    I want to Byte() equalize List(Of Byte). I'm waiting for your help and Thank you for your interest.

    Sorry for my language errors trying to fix.


    • Edited by Anonimersder Thursday, December 26, 2019 5:12 PM edit
    Thursday, December 26, 2019 5:10 PM

Answers


  • Dim dataList As New List(Of Byte())

    Dim byteArray(dataList.Count - 1) As Byte 'byteArray = dataList ?

    I want to Byte() equalize List(Of Byte). 

    Explain what you're trying to do. It looks to me like you have a List of 
    Byte arrays, not a List of Bytes. Then you're trying to copy the elements 
    (arrays) from that List to an array of Bytes.

    If you had a List of Bytes you can copy them to an array easy enough:

    'Dim dataList As New List(Of Byte())

    Dim dataList As New List(Of Byte) dataList.Add(AscW("a")) dataList.Add(AscW("Z")) Dim byteArray(dataList.Count - 1) As Byte byteArray = dataList.ToArray()


    - Wayne

    • Marked as answer by Anonimersder Thursday, December 26, 2019 7:45 PM
    Thursday, December 26, 2019 6:58 PM

All replies

  • dataList.toarray

    Success
    Cor

    Thursday, December 26, 2019 6:06 PM

  • Dim dataList As New List(Of Byte())

    Dim byteArray(dataList.Count - 1) As Byte 'byteArray = dataList ?

    I want to Byte() equalize List(Of Byte). 

    Explain what you're trying to do. It looks to me like you have a List of 
    Byte arrays, not a List of Bytes. Then you're trying to copy the elements 
    (arrays) from that List to an array of Bytes.

    If you had a List of Bytes you can copy them to an array easy enough:

    'Dim dataList As New List(Of Byte())

    Dim dataList As New List(Of Byte) dataList.Add(AscW("a")) dataList.Add(AscW("Z")) Dim byteArray(dataList.Count - 1) As Byte byteArray = dataList.ToArray()


    - Wayne

    • Marked as answer by Anonimersder Thursday, December 26, 2019 7:45 PM
    Thursday, December 26, 2019 6:58 PM
  • If what you were trying to do was copy a List of Byte arrays to an array
    of byte arrays:

    Dim dataListofBa As New List(Of Byte())
    dataListofBa.Add(byteArray)
    
    Dim byteArrayArrays(dataList.Count - 1)() As Byte
    byteArrayArrays = dataListofBa.ToArray()
    
    

    - Wayne

    Thursday, December 26, 2019 7:19 PM