using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ArraySample
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //建立一维数组
            int[] ar = new int[3];
            Display(ar);
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            //建立移位数组并设置初值
            int[] ar = { 1, 2, 3 };
            Display(ar);
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            //建立二维数组
            int[,] ar2 = new int[3, 50];
            Display(ar2);
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            //建立二维数组并设置初值
            int[,] ar2 = { { 10, 20 }, { 30, 40 }, { 50, 60 } };
            Display(ar2);
        }

        private void button5_Click(object sender, RoutedEventArgs e)
        {
            //建立不规则数组
            int[][] grades = new int[3][];
            grades[0] = new int[50];
            grades[1] = new int[25];
            grades[2] = new int[25];
            Display(grades);
        }

        private void Display(Array array) {
            MessageBox.Show("数组长度为：" + array.Length);
        }
    }
}
