C# ArrayList 怎样创建实例?

hinada99 2010-07-13 03:52:14
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ArrayList
{
class Program
{

static void Main(string[] args)
{
ArrayList listarray = new ArrayList();

int n = 5;
char[] temp_char = new char[n];


for (int i = 65; i < 65 + n; i++)
{

for (int j = 0; j < n; j++)
{
temp_char[j] = Convert.ToChar(j + i);
}

listarray.Add(temp_char);

}

Console.WriteLine(listarray.Count);

foreach (char[] m in listarray)
{
Console.WriteLine(m);
}

}
}
}


编译的时候显示: ArrayList是“命名空间”,不能被当做类型使用

这个问题怎么解决? 在线=答案
各位大侠,拜托,拜托了
...全文
395 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
幻想多巴胺 2010-07-14
  • 打赏
  • 举报
回复
//问题简化下,这个ArrayList为什么实例化失败
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace T_ArrayList
{
class Program
{

static void Main(string[] args)
{
ArrayList listarray = new ArrayList();

listarray.Add("I am");


}
}
}

看下这样行不? ArrayList这不是一个类吗
hinada99 2010-07-13
  • 打赏
  • 举报
回复
//问题简化下,这个ArrayList为什么实例化失败
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ArrayList
{
class Program
{

static void Main(string[] args)
{
ArrayList listarray = new ArrayList();

listarray.Add("I am");


}
}
}

hinada99 2010-07-13
  • 打赏
  • 举报
回复
在线=哦

1,978

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧