using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DllTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 引入dll中的排序接口Sort
        /// </summary>
        /// <param name="A">待排序的数组</param>
        /// <param name="n">数组长度</param>
        /// <returns></returns>
        [DllImport(@"F:\Program\VS2013_data\BinarySort\Debug\BinarySort.dll", EntryPoint = "Sort", CallingConvention = CallingConvention.Cdecl)]
        public static extern int Sort(int[] A, int n);

        private void button1_Click(object sender, EventArgs e)
        {
            int[] A = { 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
            int result = Sort(A, 35);   // 对数组A 从小到大排序

            MessageBox.Show(result + "");
        }

    }
}
