Advertisement
LeeMace

Check for Even Number

May 12th, 2023 (edited)
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | Gaming | 0 0
  1. //check if a number is even
  2.  
  3.  public bool IsItEven(int number) {
  4.  
  5.         return number % 2 == 0;
  6.     }
  7.  
  8. //shorter version
  9. public static bool IsEven(int number) => number % 2 == 0;
  10.  
  11. //shitty way to do it as the if which is a bool check checks the bool check
  12.     public bool EvenNumber(int num) {
  13.         if (num % 2 == 0) {
  14.             return true;
  15.         } else {
  16.             return false;
  17.         }
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement