BaseClass5.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using static System.Net.Mime.MediaTypeNames;
  7. namespace Library7Inheritance
  8. {
  9. internal class BaseClass5
  10. {
  11. protected string str;
  12. public BaseClass5(string str)
  13. {
  14. this.str = str;
  15. }
  16. public virtual string GetText()
  17. {
  18. return str;
  19. }
  20. }
  21. internal class NewClass5 : BaseClass5
  22. {
  23. protected string str2;
  24. public NewClass5(string str, string str2) : base(str)
  25. {
  26. this.str2 = str2;
  27. }
  28. public override string GetText()
  29. {
  30. return str + " " + str2;
  31. }
  32. public void SplitText(string str3)
  33. {
  34. string[] parts = str3.Split(' ');
  35. if (parts.Length >= 2)
  36. {
  37. str = parts[0];
  38. str2 = parts[1];
  39. }
  40. else
  41. {
  42. str = str3;
  43. str2 = "";
  44. }
  45. }
  46. public override string ToString()
  47. {
  48. return $"NewClass5: {str} {str2}";
  49. }
  50. }
  51. }