Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. public static bool ArrayElementsAreEqual(string[] arrayToCheck)
  2. {
  3.     if (arrayToCheck == null || arrayToCheck.Length == 0)
  4.     {
  5.         // Empty arrays are considered equal I guess?
  6.         return true;
  7.         // Or throw an error
  8.         // throw new Exception("wtf");
  9.     }
  10.  
  11.     var firstChar = arrayToCheck[0];
  12.     var lastIndex = arrayToCheck.Length - 1;
  13.     for()
  14.     for (var index = 1; index <= lastIndex; index++)
  15.     {
  16.         if (arrayToCheck[index] != firstChar)
  17.         {
  18.             return false;
  19.         }
  20.     }
  21.     return true;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement