【问题标题】:How to convert php array to c# array?如何将php数组转换为c#数组?
【发布时间】:2018-08-13 11:14:43
【问题描述】:

我想分配tax_id的值,在php找到了解决方案,但我想用c#实现,请看看

这是 php 代码,'tax_id'=>array(array(6,0,array(13))) 谁能在c#中转换这段代码sn-ps,谢谢

【问题讨论】:

  • array(6,0,array(13)) 中,[0] 是一个 int,[1] 是一个 int,[2] 是一个 Int[],其中 [0] 是一个 int。在 C# 中,事物是类型,该数组的元素要么是 Int,要么是 Array of int,但它们不能同时是两者。它是一个 3D 数组吗?是 6 和 0 这个例子是只有一个元素的 int[] 吗?

标签: c# php asp.net .net arrays


【解决方案1】:

也许你不想要一个 3D 锯齿状数组:

var jagged3D= new int[][][]
{
    new  int[][]{
         new int[]{6},
         new int[]{0},
         new int[]{13}
     }
};

或自定义对象的 2DJagged

var jaggedCustom = new Custom[][] {
    new Custom[]{
        new Custom{
            A =3,
            B =0,
            C = new int[]{13}
        }
    }
};

但是数组的所有元素都具有相同的类型。您可以通过 Msdn documentation 了解有关单维数组、多维数组、锯齿状数组的更多信息。使用左侧面板进行导航。

【讨论】:

    猜你喜欢
    • 2017-03-29
    • 2014-11-25
    • 2014-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-03
    • 2011-03-05
    相关资源
    最近更新 更多