fork download
  1. using static System.Console;
  2.  
  3. public class GotoTest1 {
  4. static void Main() {
  5. int x = 2, y = 4;
  6. var count = 0;
  7. var array = new string[x, y];
  8. for (int i = 0; i < x; i++)
  9. for (int j = 0; j < y; j++)
  10. array[i, j] = (++count).ToString();
  11. Write("Enter the number to search for: ");
  12. var myNumber = ReadLine();
  13. bool found = Search(array, x, y, myNumber);
  14. if (found) WriteLine($"The number {myNumber} is found.");
  15. else WriteLine($"The number {myNumber} was not found.");
  16. WriteLine("End of search.");
  17. }
  18. private static bool Search(string[,] array, int x, int y, string myNumber) {
  19. for (int i = 0; i < x; i++) for (int j = 0; j < y; j++) if (array[i, j] == myNumber) return true;
  20. return false;
  21. }
  22. }
  23.  
  24. //https://pt.stackoverflow.com/q/438623/101
Success #stdin #stdout 0.02s 16252KB
stdin
1
stdout
Enter the number to search for: The number 1 is found.
End of search.