数组转DataTable

来源:互联网 发布:关于训练记忆力的软件 编辑:程序博客网 时间:2024/05/02 20:47
 调用
using System;   using System.Collections.Generic;   using System.ComponentModel;   using System.Data;   using System.Drawing;   using System.Text;   using System.Windows.Forms;     namespace ArrayToDataTable   {       public partial class Form1 : Form      {           public Form1()           {              InitializeComponent();           }           private void button1_Click(object sender, EventArgs e)           {               dataGridView1.DataSource = ArrayToDataTable.Convert("haha", new string[] { "1", "2", "3", "4", "5", "6" });           }           private void button2_Click(object sender, EventArgs e)             {               string[,] array3D = {                                    { "1", "数组转DataTable 1", "0"},                                    { "2", "数组转DataTable 2", "1"},                                    { "3", "数组转DataTable 3", "1"},                                    { "4", "数组转DataTable 4", "2"},                                    { "5", "数组转DataTable 5", "2"},                                   { "6", "数组转DataTable 6", "5"},                                    };               dataGridView1.DataSource = ArrayToDataTable.Convert(new string[] { "haha1", "haha2", "haha3" }, array3D);           }           private void button3_Click(object sender, EventArgs e)           {               string[,] array3D = {                                    { "1", "数组转DataTable 1", "0"},                                    { "2", "数组转DataTable 2", "1"},                                    { "3", "数组转DataTable 3", "1"},                                    { "4", "数组转DataTable 4", "2"},                                    { "5", "数组转DataTable 5", "2"},                                    { "6", "数组转DataTable 6", "5"},                                    };               dataGridView1.DataSource = ArrayToDataTable.Convert(array3D);           }           private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)           {               System.Diagnostics.Process.Start("Iexplore.exe", "http://www.yongfa365.com/");           }       }   }