注册 登录
编程论坛 C# 论坛

C#,不知道这是什么问题

xintuhai 发布于 2014-10-13 15:08, 799 次点击
using System;
using System.Collections;

namespace ArrayList
{
    class ArrayList
    {
        static void Main(string[] args)
        {

            ArrayList arr = new ArrayList();
            string str1;
            while (true)
            {
                Console.WriteLine("Please add a string to ArrayList! ");
                str1 = Console.ReadLine();
                if (str1 == "end")
                    break;
                arr.Add(str1);
                Console.WriteLine();
                for (int i =0; i<arr.Count; i++)
                    Console.Write("{0} ",arr[i]);
                Console.WriteLine("\n");


            }
        }
    }
}
提示错误: 错误    1    “ArrayList.ArrayList”不包含“Add”的定义,并且找不到可接受类型为“ArrayList.ArrayList”的第一个参数的扩展方法“Add”(是否                       缺少 using 指令或程序集引用?)   
错误    2    “ArrayList.ArrayList”不包含“Count”的定义,并且找不到可接受类型为“ArrayList.ArrayList”的第一个参数的扩展方法“Count”(是否缺少 using 指令或程序集引用?)
错误    3    无法将带 [] 的索引应用于“ArrayList.ArrayList”类型的表达式
4 回复
#2
afdoa832014-10-13 17:47
你的类名跟公共类名重了。
#3
xintuhai2014-10-13 18:32
回复 2 楼 afdoa83
好喜爱那个还有别的问题啊。class ArrayList 改成了class ArrList.提示

错误    1    “ArrayList”是“命名空间”,但此处被当做“类型”来使用   
错误    2    “ArrayList”是“命名空间”,但此处被当做“类型”来使用
#4
afdoa832014-10-13 18:45
System.Collections.ArrayList arr =new System.Collections.ArrayList();
#5
xintuhai2014-10-13 18:49
回复 3 楼 xintuhai
明白了
1