我想创建一个派生类,我收到每个构造函数的语法错误。构造函数的定义:接收“没有参数给出”
没有给定参数对应于“Parent.Parent(父)”的要求正式 参数“P”
这没有任何意义,我。这是一个构造函数的定义,不是一个方法调用,我从来没有看到过这个不是调用的东西。
namespace ConsoleApp1
{
public class Parent
{
public string Label;
public Parent(Parent p)
{
Label = p.Label;
}
}
public class Child : Parent
{
public string Label2;
public Child(Parent p)
{
Label = p.Label;
}
public Child(Child c)
{
Label = c.Label;
Label2 = c.Label2;
}
public Child(string blah, string blah2)
{
Label = blah;
}
}
class Program
{
static void Main(string[] args)
{
}
}
}
今后,这将是最好减少您的问题到'[mcve'] - 在这种情况下,基类与参数的构造(理想的是普通型的,如'string')以及具有单个构造函数的派生类。将错误消息显示为文本而不是图像... –
我确实将错误消息显示为文本..... – TheColonel26
因此,您不需要将它显示为图像。该图像实际上并没有添加任何其他内容,只是显示它是具有红色小方格的类名 - 这是您刚才可以轻易描述的。 –