Inheritance Xamarin:从AlertDialog类继承
我正在尝试编写从AlertDialog类继承的类,但收到编译错误“'Android.App.AlertDialog'不包含接受0个参数的构造函数” 这是我的代码,简单明了Inheritance Xamarin:从AlertDialog类继承,inheritance,xamarin,android-alertdialog,Inheritance,Xamarin,Android Alertdialog,我正在尝试编写从AlertDialog类继承的类,但收到编译错误“'Android.App.AlertDialog'不包含接受0个参数的构造函数” 这是我的代码,简单明了 class AlertDialogExtender : AlertDialog { } 我试图添加一个空构造函数以符合错误消息,但没有成功 class AlertDialogExtender : AlertDialog { public AlertDialogExtender() { } } 您
class AlertDialogExtender : AlertDialog
{
}
我试图添加一个空构造函数以符合错误消息,但没有成功
class AlertDialogExtender : AlertDialog
{
public AlertDialogExtender()
{
}
}
您需要显式地从超类调用一个现有构造函数。错误告诉您,
Android.App.AlertDialog
中没有零参数构造函数。页面列出了可用的构造函数
调用超级构造函数的一般方法如下所示:
class AlertDialogExtender : AlertDialog
{
public AlertDialogExtender() : base(/* params for super constructor */) { }
}
传递给base
的参数可以是常量(例如MyClass():base(“value”)
),也可以是当前类的构造函数中的参数(例如MyClass(字符串x):base(x)
)
有关更多详细信息,请参阅