在C#中ArrayList与传统数组间的转换
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace ArrayListSample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string[] departs = new string[4];
departs[0] = "depart 1";
departs[1] = "depart 2";
departs[2] = "depart 3";
departs[3] = "depart 4";
ArrayList departsList = ArrayListSample.Adapter(departs);
listBox1.DataSource = departsList;
}
private void button1_Click(object sender, EventArgs e)
{
ArrayList tmpList = ArrayListSample.Adapter(listBox1.Items);
Array newDeparts = tmpList.ToArray();
listBox2.DataSource = newDeparts;
}
}
}
命名空间“ArrayListSample”中不存在类型或命名空间名称“Adapter”(是缺少程序集引用吗?) E:\C#实\ArrayListSample\ArrayListSample\Form1.cs
这个错误怎么处理??? 展开
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace ArrayListSample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string[] departs = new string[4];
departs[0] = "depart 1";
departs[1] = "depart 2";
departs[2] = "depart 3";
departs[3] = "depart 4";
ArrayList departsList = ArrayListSample.Adapter(departs);
listBox1.DataSource = departsList;
}
private void button1_Click(object sender, EventArgs e)
{
ArrayList tmpList = ArrayListSample.Adapter(listBox1.Items);
Array newDeparts = tmpList.ToArray();
listBox2.DataSource = newDeparts;
}
}
}
命名空间“ArrayListSample”中不存在类型或命名空间名称“Adapter”(是缺少程序集引用吗?) E:\C#实\ArrayListSample\ArrayListSample\Form1.cs
这个错误怎么处理??? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询