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.
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 });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With