小编pon*_*dle的帖子

更快的代码从字节数组中删除第一个元素

所以我有一个字节数组,我需要从中删除前5个元素.无论如何,我在网上看了一下,找不到任何适合我想要的东西.所以我做了这个,它本质上是非常缓慢的,无法使用.

        private byte[] fR(byte[] tb)
        {
            string b = "";
            byte[] m = new byte[tb.Length - 5];
            for (int a = 5; a < tb.Length; a++)
            {
                b = b + " " + tb.GetValue(a);
            }
            b = b.Remove(0, 1);
            string[] rd = Regex.Split(b, " ");
            for (int c = 0; c < rd.Length; c++)
            {
                byte curr = Convert.ToByte(rd[c]);
                m.SetValue(curr, c);
            }
            return m;
         }
Run Code Online (Sandbox Code Playgroud)

我要问的是,是否有办法让这更快/更好.或者我可以从字节数组中删除前5个元素的另一种方法.

c# algorithm bytearray

-4
推荐指数
2
解决办法
6385
查看次数

标签 统计

algorithm ×1

bytearray ×1

c# ×1