Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication11
- {
- class Student
- {
- DateTime data;
- string name;
- public Student(string _name, System.DateTime _data)
- {
- name = _name;
- data = _data;
- }
- public string Name
- {
- get { return name; }
- set { value = name; }
- }
- public DateTime Data
- {
- get { return data; }
- set { value = data; }
- }
- public override string ToString()
- {
- return string.Format("{0} {1}", name, data.ToString());
- }
- }
- class MyList
- {
- Student[] M;
- int count;
- public MyList(ConsoleApplication11.Student[] st)
- {
- M = new Student[st.Length];
- M = st;
- }
- public int Count
- {
- get { return count; }
- set { value = count; }
- }
- public System.Collections.IEnumerable GetEnumerator()
- {
- for (int i = 0; i < count; i++)
- yield return M[i];
- }
- public static ConsoleApplication11.MyList addList(ConsoleApplication11.MyList obj1, ConsoleApplication11.MyList obj2)
- {
- Student[] rez = new Student[obj1.Count + obj2.Count];
- for (int i = 0; i < obj1.Count; i++)
- rez[i] = obj1.M[i];
- for (int i = 0; i < obj2.Count; i++)
- rez[i + obj1.Count] = obj2.M[i];
- return new MyList(rez);
- }
- public ConsoleApplication11.MyList ArrayFilter(string str)
- {
- Student[] rez = new Student[count];
- int k = 0;
- for (int i =0; i<count; i++)
- {
- for (int j =0; j < M[i].Name.Length - str.Length; i++)
- if (M[i].Name.Substring(j, str.Length) == str)
- {
- rez[k] = M[i];
- k++;
- }
- }
- Student[] r = new Student[k];
- Array.Copy(rez, r, k);
- return new MyList(r);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement