String s2 = BitConverter.ToString(bytes) // 82-C8-EA-17īyte decBytes2 = new byte ĭecBytes2 = Convert.ToByte(tempAry, 16) ![]() Using UTF-8 or other Encoding object will get similar results The output string is already URL friendly! The downside is it needs System.Web assembly if your project is not a web project.Ī full example: byte bytes = // A byte array contains non-ASCII (or non-readable) characters You can easily convert the output string back to byte array by using HttpServerUtility.UrlTokenDecode. ![]() If you want to use the string in a URL, you need to explicitly encode it. Note: The output string could contain '+', '/' and '='. ![]() NET built-in method to convert the string back to byte array.Ĭonvert.ToBase64String You can easily convert the output string back to byte array by using Convert.FromBase64String. There're at least four different ways doing this conversion.Įncoding's GetString, but you won't be able to get the original bytes back if those bytes have non-ASCII characters.īitConverter.ToString The output is a "-" delimited string, but there's no.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |