本文介绍了如何修复编译器错误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();
        }
    }
}

推荐答案


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

09-03 05:43