locked
Convert 2D array of String to 2D array of Byte RRS feed

  • Question

  • How to convert 2D array of String to 2D array of Byte?
    Wednesday, March 30, 2016 8:17 AM

Answers

  • well,I'm working on large text file and I have problem with speed of program ,so I was thinking to read it as string array and make some proccessing on it,then convert it to byte array for fast proccessing

    You can convert a string into an array of bytes.  See:
    https://msdn.microsoft.com/en-us/library/ms172828.aspx?f=255&MSPPError=-2147217396

    Therefore you could convert an array of string into an array of byte arrays, by converting each element of the string array into a byte array.

    But I doubt it is going to improve your pocessing speed.

    Wednesday, March 30, 2016 9:10 AM
  • well,I'm working on large text file and I have problem with speed of program ,so I was thinking to read it as string array and make some proccessing on it,then convert it to byte array for fast proccessing

     

    Typically this means that the file needs to be processed from a stream, not as one giant string loaded into memory.  If you do all processing by manipulating the stream position you can probably get the speed increase you are looking for.

    Without any idea of what the actual processing is, it is impossible to provide any more specific suggestions.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, March 30, 2016 7:05 PM

All replies

  • Rasha,

    It is impossible to fit a string  in a byte. Maybe you mean a character but that is also impossible. A byte is 8 bits, a character can be 16 or more. 

    Maybe you want to do some compression, but that is another kind of taste. 


    Success
    Cor

    Wednesday, March 30, 2016 8:27 AM
  • well,I'm working on large text file and I have problem with speed of program ,so I was thinking to read it as string array and make some proccessing on it,then convert it to byte array for fast proccessing

     

    Wednesday, March 30, 2016 8:38 AM
  • well,I'm working on large text file and I have problem with speed of program ,so I was thinking to read it as string array and make some proccessing on it,then convert it to byte array for fast proccessing

    You can convert a string into an array of bytes.  See:
    https://msdn.microsoft.com/en-us/library/ms172828.aspx?f=255&MSPPError=-2147217396

    Therefore you could convert an array of string into an array of byte arrays, by converting each element of the string array into a byte array.

    But I doubt it is going to improve your pocessing speed.

    Wednesday, March 30, 2016 9:10 AM
  • @Acamar, 

    I did read a 2D array of string, not a string to a byte array but maybe was meant simply one long string. .


    Success
    Cor

    Wednesday, March 30, 2016 11:28 AM
  • Yes, I'm talking about 2D array ..
    Wednesday, March 30, 2016 2:30 PM
  • well,I'm working on large text file and I have problem with speed of program ,so I was thinking to read it as string array and make some proccessing on it,then convert it to byte array for fast proccessing

     

    Typically this means that the file needs to be processed from a stream, not as one giant string loaded into memory.  If you do all processing by manipulating the stream position you can probably get the speed increase you are looking for.

    Without any idea of what the actual processing is, it is impossible to provide any more specific suggestions.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, March 30, 2016 7:05 PM