Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication51
  7. {
  8. class Student
  9. {
  10. string name;
  11. DateTime data;
  12. public Student(string name, DateTime data)
  13. {
  14. this.data = data;
  15. this.name = name;
  16. }
  17. public string Name
  18. {
  19. get { return name; }
  20. set { name = value; }
  21. }
  22. public DateTime Data
  23. {
  24. get { return data; }
  25. set { data = value; }
  26. }
  27. public override string ToString()
  28. {
  29. return string.Format("name: {0}\tdate: {1}\t", name, data);
  30. }
  31. }
  32. class MyList
  33. {
  34. int count;
  35. Student[] M;
  36. public MyList(Student[] M)
  37. {
  38. this.M = M;
  39. }
  40. public int Count
  41. {
  42. get { return count; }
  43. set { count = value; }
  44. }
  45. public static MyList addList(MyList obj1, MyList obj2)
  46. {
  47. int A = obj1.M.Length;
  48. int O = obj2.M.Length;
  49. int k = obj1.count + obj2.count;
  50. Student[] S = new Student[k];
  51. MyList obj3 = new MyList(S);
  52. for (int i = 0; i < k; i++)
  53. {
  54. if (i < obj1.count) obj3.M[i] = obj1.M[i];
  55. else obj3.M[i] = obj2.M[i - obj1.count];
  56. }
  57. return obj3;
  58. }
  59. public System.Collections.IEnumerator GetEnumerator()
  60. {
  61. int o = M.Length;
  62. for (int i = 0; i < this.Count; i++)
  63. {
  64. yield return M[i];
  65. }
  66. }
  67. }
  68. class Program
  69. {
  70. static void Main(string[] args)
  71. {
  72. Student[] obj1 = new Student[3];
  73. obj1[0] = new Student("Nadya", new DateTime(2015, 08, 14));
  74. obj1[1] = new Student("Marina", new DateTime(2019, 08, 14));
  75. obj1[2] = new Student("Ulia", new DateTime(2020, 08, 14));
  76. MyList st = new MyList(obj1);
  77. st.Count = 3;
  78. Student[] obj2 = new Student[2];
  79. obj2[0] = new Student("Elina", new DateTime(2015, 08, 14));
  80. obj2[1] = new Student("Ulia", new DateTime(2016, 08, 14));
  81. MyList st2 = new MyList(obj2);
  82. st2.Count = 2;
  83. MyList.addList(st, st2);
  84. MyList kon = MyList.addList(st, st2);
  85. foreach (Student x in kon)
  86. Console.WriteLine(x);
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement