Advertisement
double_trouble

interface(remove)

Jun 20th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication11
  7. {
  8.     class Person
  9.     {
  10.         int age;
  11.         DateTime data;
  12.         string name;
  13.  
  14.         public Person(string _name, int _age, System.DateTime _data)
  15.         {
  16.             name = _name;
  17.             age = _age;
  18.             data = _data;
  19.         }
  20.  
  21.         public override string ToString()
  22.         {
  23.             return string.Format("{0} {1} {2}", name, age, data);
  24.         }
  25.     }
  26.  
  27.     interface Ind
  28.     {
  29.         void Remove(int k);
  30.         int Count {get; set;}
  31.         Person this[int ind] { get; set; }
  32.     }
  33.  
  34.     class MyClass:Ind
  35.     {
  36.         Person[] M;
  37.         int count;
  38.  
  39.         int Ind.Count
  40.         {
  41.             get
  42.             {
  43.                 return count;
  44.             }
  45.  
  46.             set
  47.             {
  48.                 value = count;
  49.             }
  50.         }
  51.  
  52.         Person Ind.this[int ind]
  53.         {
  54.             get
  55.             {
  56.                 return M[ind];
  57.             }
  58.  
  59.             set
  60.             {
  61.                 value = M[ind];
  62.             }
  63.         }
  64.  
  65.         public MyClass(ConsoleApplication11.Person[] ar)
  66.         {
  67.             M = new Person[ar.Length];
  68.             Array.Copy(ar, M, ar.Length);
  69.             count = ar.Length;
  70.         }
  71.  
  72.         public System.Collections.IEnumerator GetEnumerator()
  73.         {
  74.             for (int i = 0; i < count; i++)
  75.                 yield return M[i];
  76.         }
  77.  
  78.         void Ind.Remove(int k)
  79.         {
  80.             count--;
  81.             for (int i = k; i < count; i++)
  82.                 M[i] = M[i + 1];
  83.         }
  84.     }
  85.  
  86.     class Program
  87.     {
  88.         static void Main(string[] args)
  89.         {
  90.            
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement