Esempio n. 1
0
        public static void Main(string[] args)
        {
            CustomGenericList <string> CustomGenericList = new CustomGenericList <string>();

            //added digimon
            CustomGenericList.Add("Agumon");
            CustomGenericList.Add("Gabumon");
            CustomGenericList.Add("WarGreymon");
            CustomGenericList.Add("Angelmon");
            CustomGenericList.Add("Leomon");
            CustomGenericList.Add("Palamon");
            CustomGenericList.Print();
            Console.ReadLine();

            //removed 1
            Console.WriteLine("Removed Leomon from arrayList");
            CustomGenericList.RemoveAt("Leomon");
            CustomGenericList.Print();
            Console.ReadLine();

            string GenericString = CustomGenericList.GenericString();

            Console.WriteLine(GenericString);
            Console.ReadLine();

            //count
            Console.WriteLine("There are {0} digimon in my arrayList now.", CustomGenericList.Count());
            CustomGenericList.Print();
            Console.ReadLine();


            Console.WriteLine("\nOverload + Operator to add two instances of my custom class.");
            CustomGenericList <string> TempList = new CustomGenericList <string>();

            TempList.Add("4");
            TempList.Add("7");
            TempList.Add("1");

            CustomGenericList <string> CombineList = new CustomGenericList <string>();

            CombineList = CustomGenericList + TempList;
            CombineList.Print();
            Console.ReadLine();

            Console.WriteLine("\nOverload - Operator to remove one custom list from another.");
            CustomGenericList <string> RemoveFromList = new CustomGenericList <string>();

            RemoveFromList = CustomGenericList - TempList;
            RemoveFromList.Print();
            Console.ReadLine();

            //Zipper
            Console.WriteLine("\nZipper two Custom Lists");
            CustomGenericList <string> ZipList = new CustomGenericList <string>();

            ZipList.Zipper(CustomGenericList, TempList);
            ZipList.Print();
            Console.ReadLine();
        }
Esempio n. 2
0
        public static CustomGenericList <T> operator +(CustomGenericList <T> List1, CustomGenericList <T> List2)
        {
            CustomGenericList <T> combinedLists = new CustomGenericList <T>();

            foreach (T item in List1.innerArray)
            {
                combinedLists.Add(item);
            }
            foreach (T item in List2.innerArray)
            {
                combinedLists.Add(item);
            }
            return(combinedLists);
        }
Esempio n. 3
0
 public void Zipper(CustomGenericList <T> List1, CustomGenericList <T> List2)
 {
     if (List1.innerArray.Length > List2.innerArray.Length || List1.innerArray.Length < List2.innerArray.Length || List1.innerArray.Length == List2.innerArray.Length)
     {
         for (int i = 0; i < List2.innerArray.Length; i++)
         {
             Console.WriteLine("{0} \t{1}", List1.innerArray[i], List2.innerArray[i]);
         }
         for (int i = List2.innerArray.Length; i < List1.innerArray.Length; i++)
         {
             Console.WriteLine("{0}", List1.innerArray[i]);
         }
     }
 }