static void Main(string[] args) { FirstExample firstExample = new FirstExample(5); NDArray nDArray = new NDArray(); JaggedArrays jaggedArrays = new JaggedArrays(); DifferentArrays differentArrays = new DifferentArrays(); int[] array = { 1, 2, 3 }; ImplicitTypeArrays implicitType = new ImplicitTypeArrays(3, array); Console.ReadKey(); }
static void Main(string[] args) { /*ArraySample arraySample = new ArraySample(); * arraySample.exam(); * * InitializingArray initializingArray = new InitializingArray(); * initializingArray.exam(); * * DerivedFromArray derived = new DerivedFromArray(); * derived.exam();*/ /*MoreOnArray moreOnArray = new MoreOnArray(); * moreOnArray.exam(); * * Slices slices = new Slices(); * slices.exam();*/ /*_2DArray array1 = new _2DArray(); * array1.exam();*/ JaggedArrays jaggedArrays = new JaggedArrays(); jaggedArrays.exam(); }
public void JaggedArray() { var a = new JaggedArrays(); a.int2d = new int[][] { new int[] { 1, 2, 3 }, new int[] { 2, 3, 4 } }; a.int3d = new int[][][] { new int[][] { new int[] { 1 }, new int[] { 0, 1, 0 } }, null, new int[][] { new int[] { 0, 0, 2 }, new int[] { 0, 2, 0 }, null } }; a.class2d = new baseclass[][] { new baseclass[] { new baseclass() { Name = "a", Code = "A" }, new baseclass() { Name = "b", Code = "B" } }, new baseclass[] { new baseclass() { Name = "c" } }, null }; var s = JSON.ToJSON(a); var o = JSON.ToObject <JaggedArrays> (s); CollectionAssert.AreEqual(a.int2d[0], o.int2d[0]); CollectionAssert.AreEqual(a.int2d[1], o.int2d[1]); CollectionAssert.AreEqual(a.int3d[0][0], o.int3d[0][0]); CollectionAssert.AreEqual(a.int3d[0][1], o.int3d[0][1]); Assert.AreEqual(null, o.int3d[1]); CollectionAssert.AreEqual(a.int3d[2][0], o.int3d[2][0]); CollectionAssert.AreEqual(a.int3d[2][1], o.int3d[2][1]); CollectionAssert.AreEqual(a.int3d[2][2], o.int3d[2][2]); for (int i = 0; i < a.class2d.Length; i++) { var ai = a.class2d[i]; var oi = o.class2d[i]; if (ai == null && oi == null) { continue; } for (int j = 0; j < ai.Length; j++) { var aii = ai[j]; var oii = oi[j]; if (aii == null && oii == null) { continue; } Assert.AreEqual(aii.Name, oii.Name); Assert.AreEqual(aii.Code, oii.Code); } } }