如何修复编译器错误cs0101? [英] How do I fix compiler error cs0101?

查看:474
本文介绍了如何修复编译器错误cs0101?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

命名空间'classtester'已包含'Control'的定义。我收到此错误消息,无法弄清楚如何解决它。



"The namespace 'classtester' already contains a definition for 'Control'." I am getting this error message and couldn't figure out how to fix it.

{
    public class Control
    {
        private int top;
        private int left;
        public Control(int top, int left)
        {
            top = top;
            left = left;
        }
        public void DrawControl()
        {
            Console.WriteLine("Drawing Control at {0}, {1}", top, left);
        }
      }
    public class ListBox: Control
{
    private string mListBoxContents;
    public ListBox(int top, int left, string theContent): base(top,left)
{
    mListBoxContents = theContent;
}
    public new void DrawControl()
{
    base.DrawControl();
    Console.WriteLine("Writing string to the ListBox: {0}", mListBoxContents);
}
}
    public class Tester
    {
        public static void Main()
        {
            Control myControl = new Control (5,10);
            myControl.DrawControl();
            ListBox lb = new ListBox (20, 30, "Hello World");
            lb.DrawControl();
        }
    }
}

推荐答案

这不是一个完整的代码示例来识别问题。您在其他地方定义了类型 classtester.Control 。删除或重命名其中一个定义。



-SA
This is not a complete code sample to identify the problem. You defined the type classtester.Control somewhere else. Remove or rename one of those definitions.

—SA


这篇关于如何修复编译器错误cs0101?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆