简体   繁体   中英

C# bool return class

I started to code today, and I have a question about bool class which I cannot solve. I want to create a new bool, that after comparison the class will return a bool. this is the error I get:

'Pictureori' does not contain a constructor that takes 2 arguments

As I said, started coding just today so help is appreciated!!

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);

     }
  }

Use:

bool Ortintation = new Pictureori().tog(15,26);

Or:

Pictureori newObj = new Pictureori();
bool Ortintation = newObj.tog(15,26);

First line creates an Instance of the class, the second line is a method call.

Or, because you class doesn't have any data you could define your method as static, In that case you don't need to instance new object.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM