Advertisement
Guest User

Untitled

a guest
Oct 29th, 2021
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace CustomStack
  6. {
  7. public class StackOfString : Stack<string>
  8. {
  9. public bool IsEmpty()
  10. {
  11. if (Count == 0)
  12. {
  13. return true;
  14. }
  15. return false;
  16. }
  17.  
  18. public void AddRange(IEnumerable<string> elements)
  19. {
  20. foreach (var item in elements)
  21. {
  22. Push(item);
  23. }
  24. }
  25. }
  26. }
  27.  
  28.  
  29. using System;
  30.  
  31. namespace CustomStack
  32. {
  33. public class StartUp
  34. {
  35. static void Main(string[] args)
  36. {
  37. StackOfString myStack = new StackOfString();
  38.  
  39. Console.WriteLine(myStack.IsEmpty());
  40.  
  41. string[] array = new string[10];
  42.  
  43. for (int i = 0; i < array.Length; i++)
  44. {
  45. array[i] = $"element{i}";
  46. }
  47.  
  48. myStack.AddRange(array);
  49.  
  50. Console.WriteLine(myStack.Count);
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement