-1

Im trying to call a jagged array method but Im missing the right syntax this is my method

public static int[] CountAvrge(int[][] a)
{
}

now I want to call my CountAvrge method from the static void Main(string[] args)

something like this:

CountAvrge(new int[][] { 1, 2, 3 } {4, 5, 6});
OmG
  • 18,337
  • 10
  • 57
  • 90
Simon192
  • 9
  • 3

1 Answers1

2
int[][] array = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 } };

For the sake of completeness...

[Test]
        public void ShouldDoAnArray()
        {
            int[][] _array = new int[][] { new[] { 1, 2, 3 }, new[] { 4, 5, 6 } };
            DoSomething(_array);

        }

        public void DoSomething(int[][] array)
        {
            Assert.AreEqual(2, array.Length);
            int[] firstArray = array[0];
            Assert.AreEqual(3, firstArray.Length);
            int[] secondArray = array[1];
            Assert.AreEqual(3, secondArray.Length);
        }
dbugger
  • 15,868
  • 9
  • 31
  • 33
  • 1
    Waitaminute. This ain't no C# (although there's very little syntactic difference between the two.) – Makoto Jan 09 '15 at 17:01
  • 1
    Yeah, I just noticed. Swore it was a C# tag before, because that's where I usually stroll. – dbugger Jan 09 '15 at 17:02