Get the App
SLTechnology News&Howtos  ›  Development  › 

The conversion method between char [] and stringbyte [] and string in C #

Shulou Source: shulou.com Published: 2022-06-03 14:53:09 10月03日 Update

This article mainly explains the conversion between char [] and stringbyte [] and string in C#. The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's way of thinking to study and learn "the conversion between char [] and stringbyte [] and string in C#".

1. Conversion between char [] and string

/ / string to Char [] stringstr = "hello"; char [] arr=str.ToCharArray (); / / Char [] to stringstring str1 = new string (arr)

2. The transformation between byte [] and string

String str = "Hello, hello"; byte [] bytes;//byte [] is converted to stringbytes = Encoding.UTF8.GetBytes (str); / / string is converted to byte [] (if the string is generated by byte [], that code should be used to synthesize string) string str1 = Encoding.UTF8.GetString (bytes); bytes=Encoding.Default.GetBytes (str); string str2 = Encoding.Default.GetString (bytes)

Thank you for your reading, the above is the content of "the conversion between char [] and stringbyte [] and string in C#". After the study of this article, I believe you have a deeper understanding of the conversion between char [] and stringbyte [] and string in C#, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Between mode caching learning content coding hello characters strings that is ideas situations articles more knowledge knowledge points articles follow questions practice Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno Docker Redmi MySQL