Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 结构Cat(string,string,bool,bool)“”必须声明一个主体,因为它没有标记为抽象、外部或部分_C# - Fatal编程技术网

C# 结构Cat(string,string,bool,bool)“”必须声明一个主体,因为它没有标记为抽象、外部或部分

C# 结构Cat(string,string,bool,bool)“”必须声明一个主体,因为它没有标记为抽象、外部或部分,c#,C#,这是我的代码,我不知道是什么错误,为什么编译器会这么说 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _11._2 { class Cat { private string name = "cat"; private string type = "gizei"; private bool water = false;

这是我的代码,我不知道是什么错误,为什么编译器会这么说

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;

 namespace _11._2
{
class Cat
{
    private string name = "cat";
    private string type = "gizei";
    private bool water = false;
    private bool yalel = false;
    public Cat(string name, string type, bool water, bool yalel);
    public string meow()
    {
        if (yalel)
            return "Meow Meow Meow";
        else
            return "Meow";
    }

    public bool thirsty()
    {
        return water ? true : false;
    }

    public string info()
    {
        return "My name is " + name + " and my type is " + type;
    }
}
}
我尝试添加抽象或外部,但错误仍然存在。

试试这个

 public Cat(string name, string type, bool water, bool yalel)
  {

  }
试试这个

 public Cat(string name, string type, bool water, bool yalel)
  {

  }

这是由于以下原因:

public Cat(string name, string type, bool water, bool yalel);
这是一个构造函数声明,因此您必须为此方法声明一个主体:

public Cat(string name, string type, bool water, bool yalel)
{
   // Do something like :
   // this.name = name;
   // this.type = type;
   // etc...
}

这是由于以下原因:

public Cat(string name, string type, bool water, bool yalel);
这是一个构造函数声明,因此您必须为此方法声明一个主体:

public Cat(string name, string type, bool water, bool yalel)
{
   // Do something like :
   // this.name = name;
   // this.type = type;
   // etc...
}
尝试公共Catstring名称、字符串类型、bool water、bool yallel{/*参数到类成员赋值*/},该构造函数没有主体。您可能希望将参数分配给类成员字段。请尝试公共Catstring名称、字符串类型、bool water、bool yallel{/*参数分配给类成员,此处*/},该构造函数没有主体。您可能希望将参数分配给类成员字段。