Take the 2-minute tour ×

I want to make a file which reads String array but initially I am having only byte array so first I want to convert it into string array, so how can I do so.

share|improve this question
Use StreamReader to read strings from a file. File.ReadAllLines() is the quick way. –  Hans Passant Apr 17 '10 at 16:54
add comment

1 Answer

Try this:

Byte[] bytes = System.Text.Encoding.UTF8.GetBytes(yourString);

You may need to change this up depending on the character encoding of your string - please see System.Text.Encoding (specifically its properties) for other encodings that are supported by this type.

If you need to go the other way (and convert a Byte[] to a String) then do this (The advice on character encoding still applies here as well):

String yourString = System.Text.Encoding.UTF8.GetString(yourByteArray);

It sounds like your the API you are using expects a String[] and a call to GetString will provide you with just a single instance of String, not an array. Perhaps something like this will work for your API call:

String yourString = System.Text.Encoding.UTF8.GetString(yourByteArray);
someType.ApiCall(new[] { yourString });
share|improve this answer
add comment

Your Answer


