Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication51
- {
- class Student
- {
- string name;
- DateTime data;
- public Student(string name, DateTime data)
- {
- this.data = data;
- this.name = name;
- }
- public string Name
- {
- get { return name; }
- set { name = value; }
- }
- public DateTime Data
- {
- get { return data; }
- set { data = value; }
- }
- public override string ToString()
- {
- return string.Format("name: {0}\tdate: {1}\t", name, data);
- }
- }
- class MyList
- {
- int count;
- Student[] M;
- public MyList(Student[] M)
- {
- this.M = M;
- }
- public int Count
- {
- get { return count; }
- set { count = value; }
- }
- public static MyList addList(MyList obj1, MyList obj2)
- {
- int A = obj1.M.Length;
- int O = obj2.M.Length;
- int k = obj1.count + obj2.count;
- Student[] S = new Student[k];
- MyList obj3 = new MyList(S);
- for (int i = 0; i < k; i++)
- {
- if (i < obj1.count) obj3.M[i] = obj1.M[i];
- else obj3.M[i] = obj2.M[i - obj1.count];
- }
- return obj3;
- }
- public System.Collections.IEnumerator GetEnumerator()
- {
- int o = M.Length;
- for (int i = 0; i < this.Count; i++)
- {
- yield return M[i];
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Student[] obj1 = new Student[3];
- obj1[0] = new Student("Nadya", new DateTime(2015, 08, 14));
- obj1[1] = new Student("Marina", new DateTime(2019, 08, 14));
- obj1[2] = new Student("Ulia", new DateTime(2020, 08, 14));
- MyList st = new MyList(obj1);
- st.Count = 3;
- Student[] obj2 = new Student[2];
- obj2[0] = new Student("Elina", new DateTime(2015, 08, 14));
- obj2[1] = new Student("Ulia", new DateTime(2016, 08, 14));
- MyList st2 = new MyList(obj2);
- st2.Count = 2;
- MyList.addList(st, st2);
- MyList kon = MyList.addList(st, st2);
- foreach (Student x in kon)
- Console.WriteLine(x);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement