0
点赞
收藏
分享

微信扫一扫

C#对char[]的处理

cnlinkchina 2022-02-04 阅读 35
c#string

先来看一段简单的C#代码:

private void button3_Click(object sender, EventArgs e)
        {
            char[] a = new char[6] { 'h', 'e', 'L', 'O', '\0', '\0' };         // 少赋值一个元素都会报错
            string b = new string(a);
            string result = String.Format("b = {0}, b.Length = {1}", b, b.Length);

            MessageBox.Show(result);
        }


看下运行结果:

举报

相关推荐

0 条评论