小编Sea*_*ean的帖子

错误:父类不包含带0参数的构造函数

最初我收到一个错误,我不能在咖啡类"咖啡"中将"_coffee"命名为"_coffee",因为成员名称不能与其封闭类型相同.当我将名称更改为_coffee时,我收到一条错误"coffeeShop不包含带0参数的构造函数." 我在网上找到了解决方案,但它们似乎不适用于我的应用程序或正常工作.请帮忙.

public class coffeeShop
{
    string _size;
    string _type;
    public coffeeShop(string size, string type)
    {
        _size = size;
        _type = type;
                }
    public override string ToString()
    {
        return String.Format("Thanks for ordering: {0}, {1}", _size, _type);
    }
}
class Coffee : coffeeShop
{
    string _size;
    string _type;
    string _caffiene;
    public virtual void _Coffee( string size, string type, string caffiene)
{
    _caffiene = caffiene;
    _size = size;
    _type = type;
}
    public override string ToString()
    {
        return String.Format("Product Information for: {0} …
Run Code Online (Sandbox Code Playgroud)

c#

1
推荐指数
1
解决办法
1752
查看次数

标签 统计

c# ×1