簡體   English   中英

如何調用鋸齒數組方法?

[英]How to call a jagged array method?

我試圖調用鋸齒數組方法,但是我缺少正確的語法,這是我的方法

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

現在我想從靜態void Main(string [] args)調用CountAvrge方法

像這樣的東西:

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

為了完整性...

[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);
        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM