C#布尔返回类

C#布尔返回类,c#,C#,我今天开始编写代码,我有一个关于bool类的问题,我无法解决。我想创建一个新的bool,在比较之后,类将返回一个bool。 这是我得到的错误: “Pictureori”不包含接受2个参数的构造函数 正如我所说,今天刚开始编写代码,非常感谢您的帮助 public class Pictureori { public bool tog(int x, int y) { int picwih = x; int pichight = y; if (picwih > p

我今天开始编写代码,我有一个关于bool类的问题,我无法解决。我想创建一个新的bool,在比较之后,类将返回一个bool。 这是我得到的错误:

“Pictureori”不包含接受2个参数的构造函数

正如我所说,今天刚开始编写代码,非常感谢您的帮助

public class Pictureori
{
  public bool tog(int x, int y)
  {
    int picwih = x;
    int pichight = y;

    if (picwih > pichight)
    {
       return true;
    }
    else
    {
      return false;
    }
  }

  class Program
  {
     public static void Main(string[] args)
     {
          Console.WriteLine("Please enter picture size");
          bool Ortintation = new Pictureori(15,26);

     }
  }
使用:

或:

第一行创建类的
实例
,第二行是
方法
调用

或者,因为您的类没有任何数据,所以可以将方法定义为静态的,在这种情况下,您不需要实例化新对象

public static bool tog(int x, int y)
...
bool Ortintation =  Pictureori.tog(15,26);

Pictureori没有构造函数(只有带有0个参数的默认值),因此您不能执行
新建Pictureori(15,26)
。或者:将
tog
更改为
Pictureori
Pictureori newObj = new Pictureori();
bool Ortintation = newObj.tog(15,26);
public static bool tog(int x, int y)
...
bool Ortintation =  Pictureori.tog(15,26);