c# 字符串转换为byte

c# 字符串转换为byte

using System.Text;
class proj
{
    internal static void Main(string[] args)
    {
        byte[] a=new byte[3];
        Console.WriteLine("打印a");
        Console.WriteLine("a的长度{0}",a.Length);
        foreach (byte b in a)
        { Console.WriteLine(b); }
        a = Encoding.UTF8.GetBytes("我爱你");
        Console.WriteLine("给byte赋值");
        Console.WriteLine("a的长度{0}", a.Length);
        foreach (byte b in a)
        {  Console.WriteLine(b); }
        string c;
        c=Encoding.UTF8.GetString(a,0,9);
        Console.WriteLine(c);
    }
}

c# 字符串转换为byte_第1张图片

你可能感兴趣的:(c#开发,c#,开发语言)