cnblogs/dcrenl/字符串 (string)与字节数组(byte[])之间的转换.html
2024-09-24 12:43:01 +08:00

10 lines
375 B
HTML

<div id="sina_keyword_ad_area2" class="articalContent ">
<div>string str = &quot;abc&quot;</div>
<div>//字符串转成编码为GB2312的byte[]</div>
byte[] pData =System.Text.Encoding.GetEncoding(&quot;GB2312&quot;).GetBytes(str);
<div>//byte[]转字符串</div>
<div>str = Encoding.Default.GetString(<span style="line-height:21px">pData</span>);</div>
</div>