Beispiel #1
0
        public static myList <T> operator -(myList <T> mylist, myList <T> mylist2)
        {
            myList <T> newlist = new myList <T>();

            for (int i = 0; i < mylist.countoflist; i++)
            {
                newlist.AddToMyList(mylist[i]);
            }
            foreach (T item in newlist)
            {
                for (int x = 0; x < mylist2.countoflist; x++)
                {
                    if (item.Equals(mylist2[x]))
                    {
                        newlist.RemoveItemFromList(item);
                        mylist2.RemoveItemFromList(item);
                        for (int b = 0; b < mylist2.countoflist; b++)
                        {
                            newlist.AddToMyList(mylist2[b]);
                        }
                    }
                }
            }
            return(newlist);
        }
Beispiel #2
0
        public static myList <T> operator +(myList <T> mylist, myList <T> mylist2)
        {
            myList <T> newlist = new myList <T>();

            for (int i = 0; i < mylist.countoflist; i++)
            {
                newlist.AddToMyList(mylist[i]);
            }
            for (int i = 0; i < mylist2.countoflist; i++)
            {
                newlist.AddToMyList(mylist2[i]);
            }
            return(newlist);
        }
Beispiel #3
0
        public myList <T> ZipperDeeDooDah(myList <T> mylist, myList <T> mylist2)
        {
            myList <T> zipList = new myList <T>();

            if (mylist.countoflist != 0 && !mylist2.Equals(0))
            {
                if (countoflist >= mylist2.countoflist)
                {
                    for (int i = 0; i < countoflist; i++)
                    {
                        zipList.AddToMyList(mylist[i]);
                        if (i < mylist2.countoflist)
                        {
                            zipList.AddToMyList(mylist2[i]);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < mylist2.countoflist; i++)
                    {
                        if (i < countoflist)
                        {
                            zipList.AddToMyList(mylist[i]);
                        }
                        zipList.AddToMyList(mylist2[i]);
                    }
                }
            }
            else if (countoflist != 0 && mylist2.Equals(0))
            {
                for (int i = 0; i < countoflist; i++)
                {
                    zipList.AddToMyList(mylist[i]);
                }
            }
            else if (countoflist == 0 && !mylist2.Equals(0))
            {
                for (int i = 0; i < mylist2.countoflist; i++)
                {
                    zipList.AddToMyList(mylist2[i]);
                }
            }
            return(zipList);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            myList <int> andrewsList  = new myList <int>();
            myList <int> andrewsList2 = new myList <int>();

            andrewsList.AddToMyList(3);
            andrewsList2.AddToMyList(6);
            andrewsList.AddToMyList(9);
            andrewsList2.AddToMyList(12);
            andrewsList.AddToMyList(15);
            andrewsList2.AddToMyList(18);
            //andrewsList.RemoveItemFromList(15);
            //andrewsList.RemoveItemFromList(9);
            //Console.WriteLine(andrewsList.ToString());
            //Console.WriteLine(andrewsList2.ToString());
            //Console.ReadKey();
            //myList<int> andrewsList3 = andrewsList - andrewsList2;
            //Console.ReadKey();
            andrewsList.ZipperDeeDooDah(andrewsList, andrewsList2);
        }