将 C# 代码段转换为二维数组的 Dart

问题描述

我是 dart 编程的新手。我正在尝试将 C# 中的以下代码片段转换为 Dart。但是,我对能够移植二维数组的实现感到困惑。任何提示解决方案都会有所帮助。

public static byte[][] GetRfidBlock(byte[] arr)
        {
            int numblocks = ((arr.Length - 1) / 4) + 1;
            //byte[][] ret = new byte[numblocks][4];
            byte[][] ret = new byte[numblocks][];

            int ctr = 0;
            int ctr4 = 0;
            int ctr1stdim = 0;
            ret[ctr1stdim] = new byte[4];
            while (ctr < arr.Length)
            {
                ret[ctr1stdim][ctr4++] = arr[ctr++];
                if (ctr4 == 4)
                {
                    ctr4 = 0;
                    ctr1stdim++;
                    ret[ctr1stdim] = new byte[4];
                }
            }
            return ret;
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)