Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. foreach (var item in splittedTxt)
  2. {
  3. if (wordToFind == item)
  4. {
  5. var cursorPositionTop = Console.CursorTop;
  6. var cursorPositionLeft = Console.CursorLeft;
  7. Console.BackgroundColor = ConsoleColor.Blue;
  8. Console.ForegroundColor = ConsoleColor.White;
  9. wordFound = true;
  10.  
  11.  
  12. foundWordPositions.Add(new CursorPosition(cursorPositionTop, cursorPositionLeft));
  13. }
  14. Console.Write(item);
  15. if (wordFound) // reset color
  16. {
  17. Console.BackgroundColor = ConsoleColor.Black;
  18. Console.ForegroundColor = ConsoleColor.Gray;
  19. wordFound = false;
  20.  
  21.  
  22. }
  23.  
  24. Console.Write(" ");
  25. }
  26.  
  27. //Sets the cursor to my found results
  28. foreach (var item in foundWordPositions)
  29. {
  30. Console.SetCursorPosition(item.CursorLeftPosition, item.CursorTopPosition);
  31. Console.ReadLine();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement