RemoveAt() public method

public RemoveAt ( int index ) : void
index int
return void
Example #1
0
        /// <summary>
        /// Return the canonical form of a path.
        /// </summary>
        public static string Canonicalize( string path )
        {
            ArrayList parts = new ArrayList(
                path.Split( DirectorySeparatorChar, AltDirectorySeparatorChar ) );

            for( int index = 0; index < parts.Count; )
            {
                string part = (string)parts[index];

                switch( part )
                {
                    case ".":
                        parts.RemoveAt( index );
                        break;

                    case "..":
                        parts.RemoveAt( index );
                        if ( index > 0 )
                            parts.RemoveAt( --index );
                        break;
                    default:
                        index++;
                        break;
                }
            }

            return String.Join( DirectorySeparatorChar.ToString(), (string[])parts.ToArray( typeof( string ) ) );
        }
		/// <summary>
		/// Simple and fast label collision detection.
		/// </summary>
		/// <param name="labels"></param>
		public static IEnumerable SimpleCollisionDetection(IList labels)
		{
            ArrayList labelList = new ArrayList(labels);

			labelList.Sort(); // sort labels by intersection tests of the label's collision box

			//remove labels that intersect other labels
			for (int i = labelList.Count - 1; i > 0; i--)
			{
                Label2D label1 = labelList[i] as Label2D;
                Label2D label2 = labelList[i - 1] as Label2D;

                if (label1 == null)
                {
                    labelList.RemoveAt(i);
                    continue;
                }

                if (label1.CompareTo(label2) == 0)
				{
                    if (label1.Priority > label2.Priority)
					{
						labelList.RemoveAt(i - 1);
					}
					else
					{
						labelList.RemoveAt(i);
					}
				}
			}

			return labelList;
		}
Example #3
0
 public static void Merge(ArrayList al1, ArrayList al2)
 {
     for (int i = 0; i < al1.Count; i++)
     {
         for (int j = i + 1; j < al1.Count; j++)
         {
             int start = int.Parse(al1[i].ToString());
             int end = int.Parse(al2[i].ToString());
             int point1 = int.Parse(al1[j].ToString());
             int point2 = int.Parse(al2[j].ToString());
             if (point1 >= start && point1 <= end)
             {
                 if (point2 >= end)
                 {
                     al2[i] = (object)point2;
                 }
                 al1.RemoveAt(j);
                 al2.RemoveAt(j);
                 j -= 1;
             }
             if (point2 >= start && point2 <= end)
             {
                 if (point1 <= start)
                 {
                     al1[i] = (object)point1;
                 }
                 al1.RemoveAt(j);
                 al2.RemoveAt(j);
                 j -= 1;
             }
         }
     }
 }
Example #4
0
 public static void SwapPosition(ArrayList lista, Object node1, Object node2)
 {
     int exp1idx = lista.IndexOf(node1);
     int exp2idx = lista.IndexOf(node2);
     lista.RemoveAt(exp1idx);
     lista.Insert(exp1idx, node2);
     lista.RemoveAt(exp2idx);
     lista.Insert(exp2idx, node1);
 }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length < 2)
            {
                this.SendUsage(caller);
                return;
            }

            var name = command.GetStringParameter(0);
            var typeName = command.GetStringParameter(1).ToLower();

            if (RegionsPlugin.Instance.GetRegion(name, true) != null)
            {
                UnturnedChat.Say(caller, "A region with this name already exists!", Color.red);
                return;
            }

            var type = RegionType.RegisterRegionType(typeName);
            if (type == null)
            {
                var types = "";
                foreach (var t in RegionType.GetTypes())
                {
                    if (types == "")
                    {
                        types = t;
                        continue;
                    }

                    types += ", " + t;
                }
                UnturnedChat.Say(caller, "Unknown type: " + typeName + "! Available types: " + types, Color.red);
                return;
            }
            var args = new ArrayList(command);
            args.RemoveAt(0); // remove name...
            args.RemoveAt(0); // remove type...
            var region = type.OnCreate(caller, name, (string[]) args.ToArray(typeof(string)));

            if (region == null)
            {
                UnturnedChat.Say(caller, "Could't create region!", Color.red);
                return;
            }

            RegionsPlugin.Instance.Regions.Add(region);
            RegionsPlugin.Instance.OnRegionCreated(region);

            region.SetFlag("EnterMessage", "Entered region: {0}", new List<GroupValue>());
            region.SetFlag("LeaveMessage", "Left region: {0}", new List<GroupValue>());

            RegionsPlugin.Instance.Configuration.Save();
            UnturnedChat.Say(caller, "Successfully created region: " + name, Color.green);
        }
        public override void ReduceRects(ref ArrayList a_aRects)
        {
            //TODO: if more than N rects, sort them by area (or locX?)

            //TODO: check the area affected - if it's small, just do a join!

            int nCnt = a_aRects.Count;
            if (nCnt > 100) //more than 100 tests will take too much time - just do a join!
            {
                Rectangle rctUnion = RectsUnion(a_aRects);
                a_aRects.Clear();
                a_aRects.Add(rctUnion);
                return;
            }

            Rectangle rct = new Rectangle(0,0,0,0);
            bool bGotRect = false;
            int nCheckThisPos = nCnt-1;
            for(;;)
            {
                if (bGotRect == false)
                {
                    rct = (Rectangle)a_aRects[nCheckThisPos];
                    bGotRect = true;
                    a_aRects.RemoveAt(nCheckThisPos);
                }

                //if (m_bMakeCallback) then makeCallback(m_plCallbackInfo, me, #Draw, [#AllRects:a_aRects, #CheckThis:rct])

                int nJoinedRectAtPos = ReduceRectsSub(ref a_aRects, rct);

                //    if (m_bMakeCallback) then makeCallback(m_plCallbackInfo, me, #Draw, [#AllRects:a_aRects])

                //Added step: if there's been a join, the current dirtyRect list must be rechecked
                //because maybe the new rect should join with another
                if (nJoinedRectAtPos >= 0)
                {
                    if (a_aRects.Count == 1)
                        return;
                    rct = (Rectangle)a_aRects[nJoinedRectAtPos];
                    a_aRects.RemoveAt(nJoinedRectAtPos);
                    nCheckThisPos = a_aRects.Count;
                }
                else
                {
                    nCheckThisPos--;
                    bGotRect = false;
                    if (nCheckThisPos <= 0)
                        return;
                }
            }
        }
Example #7
0
 public static void DeleteArraylist(ArrayList arraylist) 
 {
     Console.WriteLine("количество элементов arraylist {0}", arraylist.Count);
     int del = arraylist.Count;
     Stopwatch sw = Stopwatch.StartNew();
     arraylist.RemoveAt(0);
     arraylist.RemoveAt((arraylist.Count-1)/2);
     arraylist.RemoveAt(arraylist.Count -1);
     Console.WriteLine("количество элементов arraylist после удаления {0}", arraylist.Count);
     Console.WriteLine("Время удаления из arraylist = {0}", sw.Elapsed);
     Console.ReadLine();
     
 }
Example #8
0
      static void Main(string[] args) 
      {
         // Create an ArrayList
         ArrayList al = new ArrayList();

         // Add some elements
         al.Add("foo");
         al.Add(3.7);
         al.Add(5);
         al.Add(false);

         // List them
         Console.WriteLine("Count={0}",al.Count);
         for(int i = 0; i < al.Count; i++)
            Console.WriteLine("al[{0}]={1}", i, al[i]);

         // Remove the element at index 1
         al.RemoveAt(1);

         // List them
         Console.WriteLine("Count={0}",al.Count);
         for(int i = 0; i < al.Count; i++)
            Console.WriteLine("al[{0}]={1}", i, al[i]);
            
            IEnumerator ie = al.GetEnumerator();
	    
	    while(ie.MoveNext())
	       Console.WriteLine(ie.Current);
      }
        internal static MethodInfo[] GetNonPropertyMethods(Type type)
        {
            MethodInfo[] aMethods = type.GetMethods();
            ArrayList methods = new ArrayList(aMethods);

            PropertyInfo[] props = type.GetProperties();

            foreach (PropertyInfo prop in props)
            {
                MethodInfo[] accessors = prop.GetAccessors();
                foreach (MethodInfo accessor in accessors)
                {
                    for (int i = 0; i < methods.Count; i++)
                    {
                        if ((MethodInfo)methods[i] == accessor)
                            methods.RemoveAt(i);
                    }
                }
            }

            MethodInfo[] retMethods = new MethodInfo[methods.Count];
            methods.CopyTo(retMethods);

            return retMethods;
        }
        public void fun1()
        {
            ArrayList a1 = new ArrayList();
            a1.Add(1);
            a1.Add('c');
            a1.Add("string1");

            ArrayList al2 = new ArrayList();
            al2.Add('a');
            al2.Add(5);

            int n = (int)a1[0];
            Console.WriteLine(n);
            a1[0] = 20;
            Console.WriteLine(a1.Count);
            Console.WriteLine(a1.Contains(55));
            Console.WriteLine(a1.IndexOf(55));
            //int[] num = (int[])a1.ToArray();

            a1.Add(45);
            a1.Add(12);
            a1.Add(67);

            a1.Insert(1, "new value");
            //a1.AddRange(al2);
            a1.InsertRange(1, al2);
            a1.Remove("string1");
            a1.RemoveAt(2);
            a1.RemoveRange(0, 2);

            foreach (object o in a1)
            {
                Console.WriteLine(o.ToString());
            }
        }
        /// <summary>
        /// Creates menu items for the specified MenuDefinitionEntryCollection.
        /// </summary>
        ///	<param name="commandManager">The CommandManager to use.</param>
        /// <param name="menuDefinitionEntryCollection">The MenuDefinitionEntryCollection to create menu items for.</param>
        /// <returns>The menu items.</returns>
        public static MenuItem[] CreateMenuItems(CommandManager commandManager, MenuType menuType, MenuDefinitionEntryCollection menuDefinitionEntryCollection)
        {
            ArrayList menuItemArrayList = new ArrayList();
            for (int position = 0; position < menuDefinitionEntryCollection.Count; position++)
            {
                MenuItem[] menuItems = menuDefinitionEntryCollection[position].GetMenuItems(commandManager, menuType);
                if (menuItems != null)
                    menuItemArrayList.AddRange(menuItems);
            }

            // remove leading, trailing, and adjacent separators
            for (int i = menuItemArrayList.Count - 1; i >= 0; i--)
            {
                if (((MenuItem)menuItemArrayList[i]).Text == "-")
                {
                    if (i == 0 ||  // leading
                        i == menuItemArrayList.Count - 1 ||  // trailing
                        ((MenuItem)menuItemArrayList[i - 1]).Text == "-")  // adjacent
                    {
                        menuItemArrayList.RemoveAt(i);
                    }
                }
            }

            return (menuItemArrayList.Count == 0) ? null : (MenuItem[])menuItemArrayList.ToArray(typeof(MenuItem));
        }
Example #12
0
 static void Main(string[] args)
 {
     ArrayList al = new ArrayList();
     al.Add("string");
     al.Add('B');
     al.Add(10);
     al.Add(DateTime.Now);
     ArrayList bl = new ArrayList(5);
     al.Remove('B');
     // 从al中删除第一个匹配的对象,如果al中不包含该对象,数组保持不变,不引发异常。
     al.Remove('B');
     al.RemoveAt(0);
     al.RemoveRange(0, 1);
     bl.Add(1);
     bl.Add(11);
     bl.Add(111);
     bl.Insert(4, 1111);
     int[] inttest = (int[])bl.ToArray(typeof(int));
     foreach(int it in inttest)
         Console.WriteLine(it);
     int[] inttest2 = new int[bl.Count];
     bl.CopyTo(inttest2);
     ArrayList cl = new ArrayList();
     cl.Add(1);
     cl.Add("Hello, World!");
     object[] ol = (object[])cl.ToArray(typeof(object));
     // stringp[] os = (string[])cl.ToArray(typeof(string));
     Console.WriteLine("The Capacity of new ArrayList: {0}", al.Capacity);
 }
Example #13
0
        private void button3_Click(object sender, EventArgs e)
        {
            ArrayList arr = new ArrayList();
            arr.Add(10);
            arr.Add(20); //To add a new element at the end of collection
            arr.Add(30);
            arr.Add(40);
            arr.Add(50);
            arr.Add(60);
            arr.Add(70);
            arr.Add(80);
            arr.Add(90);
            arr[3] = 400; //To overwrite the value
            MessageBox.Show(arr.Capacity.ToString());
            arr.Insert(3, 1000);//insert in the middle
            //shift the other elements =>index,value
            foreach (object obj in arr)
            {
                listBox3.Items.Add(obj.ToString());
            }

            arr[12] = 10; //Runtime error

            arr.Remove(10);  //remove 10 <=value
            arr.RemoveAt(1); //remove element at index 1 <=index
        }
Example #14
0
        private void BackSpaceButton_Click(object sender, EventArgs e)
        {
            if (txtKitchenText.Text == null || txtKitchenText.Text.Length<1)
            {
                return;
            }
            try
            {
                m_arrList = new ArrayList();
                foreach (Char obj in txtKitchenText.Text)
                {
                    m_arrList.Add(obj);
                }
                m_arrList.RemoveAt(m_arrList.Count - 1);

                string currentText = "";
                foreach (char o in m_arrList)
                {
                    currentText += o;
                }
                txtKitchenText.Text = currentText;
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //1. create empty ArrayList
            ArrayList al = new ArrayList();

            //2. add element into array list
            al.Add("Dog");
            al.Add("Cat");
            al.Add("Elephant");
            al.Add("Lion");
            al.Add("Cat");
            al.Add("Platypus");

            //3. bind above arrayList to first list box
            lbOriginal.DataSource = al;
            lbOriginal.DataBind();

            //4. change (insert -> remove ->remove)
            al.Insert(1, "Chicken~~~");
            al.Remove("Cat");
            al.RemoveAt(0);

            //5. bind the result into second list box
            lbChanged.DataSource = al;
            lbChanged.DataBind();
        }
 private CKnote ErmittleEndKnoten(ArrayList verbindungen, ArrayList knoten)
 {
     foreach (CVerbindung verbindung in verbindungen)
         for (int i = 0; i <= knoten.Count - 1; i++)
             if (verbindung.GetStart() == (CKnote)knoten[i]) knoten.RemoveAt(i);
     return (CKnote)knoten[knoten.Count - 1];
 }
Example #17
0
        public void Test(int arg)
        {
            ArrayList items = new ArrayList();
            items.Add(1);
            items.AddRange(1, 2, 3);
            items.Clear();
            bool b1 = items.Contains(2);
            items.Insert(0, 1);
            items.InsertRange(1, 0, 5);
            items.RemoveAt(4);
            items.RemoveRange(4, 3);
            items.Remove(1);
            object[] newItems = items.GetRange(5, 2);
            object[] newItems2 = items.GetRange(5, arg);

            List<int> numbers = new List<int>();
            numbers.Add(1);
            numbers.AddRange(1, 2, 3);
            numbers.Clear();
            bool b2 = numbers.Contains(4);
            numbers.Insert(1, 10);
            numbers.InsertRange(2, 10, 3);
            numbers.RemoveAt(4);
            numbers.RemoveRange(4, 2);
            int[] newNumbers = items.GetRange(5, 2);
            int[] newNumbers2 = items.GetRange(5, arg);

            string[] words = new string[5];
            words[0] = "hello";
            words[1] = "world";
            bool b3 = words.Contains("hi");
            string[] newWords = words.GetRange(5, 2);
            string[] newWords2 = words.GetRange(5, arg);
        }
        public Cliente_Admin(bool cumple)
        {
            InitializeComponent();
            cbox_filtro_producto.SelectedIndex = 0;

            ArrayList lista = new ArrayList();

            // nombre
            if (cbox_filtro_producto.SelectedIndex == 0)
            {

                string buscarse = "and c.nombre like '%%'";
                lista = DatosCliente.getClientes(buscarse);
            }

            for (int x = lista.Count; x > 0; x--)
            {
                if (((Cliente)lista[x - 1]).Nacimiento.Day != DateTime.Today.Day || ((Cliente)lista[x - 1]).Nacimiento.Month != DateTime.Today.Month)
                {
                    lista.RemoveAt(x - 1);

                }

            }
            listaVacia.Clear();
            listaVacia = lista;
            bdd_clientes.DataSource = listaVacia;
        }
Example #19
0
        static void Main(string[] args)
        {
            Console.Write(@"В кругу стоят N человек, пронумерованных от 1 до N.
            При ведении счета по кругу вычёркивается каждый
            второй человек, пока не останется один.
            Введите количество человек: ");
            int n = int.Parse(Console.ReadLine());
            ArrayList array = new ArrayList(n);
            for (int t = 1; t <= n; t++)
            {
                array.Add(t);
                Console.Write(array[t - 1] + " ");
            }
            Console.WriteLine("\n\nОтдельное вычеркивание каждого второго элемента");
            int i = 1;

            while (array.Count != 1)
            {
                array.RemoveAt(i);
                ++i;

                if (i > array.Count) { i = 1; }
                if (i == array.Count) { i = 0; }
                for (int t = 0; t < array.Count; t++)
                {
                    Console.Write(array[t] + " ");
                }
                Console.WriteLine();

            }

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            ArrayList a = new ArrayList();
            a.Add(123);
            a.Add("BARD");
            a.Add(34.689);
            a.Insert(2, 'A');
            a.Remove(123);
            a.RemoveAt(2);
            foreach (Object o in a)
            {
                Console.WriteLine(o.ToString());
            }

            //Student s = new Student();
            //s.GetData();
            //a.Add(s);
            //foreach (Object o in a)
            //{
            //    if (o.GetType().ToString() == "ArrayListSample.Student")
            //    {
            //        Student s1 = (Student)o;
            //        s1.ShowData();
            //    }
            //}
            //Console.WriteLine("No of elements are:" +a.Count);

            Console.Read();
        }
Example #21
0
 /// <summary>
 /// Splits string consisting of fields separated by
 /// whitespace into an array of strings.
 /// </summary>
 /// <param name="str">string to split</param>   
 public static string[] Split(string str)
 {
     ArrayList allTokens = new ArrayList(str.Split(null));
     for (int i = allTokens.Count - 1; i >= 0; i--)
         if (((string)allTokens[i]).Trim().Length == 0)
             allTokens.RemoveAt(i);
     return (string[])allTokens.ToArray(typeof(string));
 }
 public void CurvefitValue(int x)
 {
     for (int i = 0; i < Coefficients.Count(); i++)
         PolyfitValue += Coefficients[i] * Math.Pow(x, i);
     ArrayList al = new ArrayList(Predictions);
     al.RemoveAt(0);
     al.Add(PolyfitValue);
     PredictionsNew = (double[])al.ToArray(typeof(double));
 }
Example #23
0
        public void TestAddAndRemove()
        {
            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);

            int[] in4a = new int[9];

            // Construct, and verify small capacity
            ArrayList al2 = new ArrayList(1);
            in4a[0] = al2.Capacity;
            Assert.Equal(1, in4a[0]);

            // Add the first obj
            sbl3.Length = 0;
            sbl3.Append("hi mom");

            al2.Add(sbl3);
            sbl4 = (StringBuilder)al2[0];

            Assert.Equal(sbl4.ToString(), sbl3.ToString());

            // Add another obj, verify that Add auto increases Capacity when needed.
            sbl3.Length = 0;
            sbl3.Append("low dad");

            al2.Add(sbl3);
            in4a[1] = al2.Capacity;
            Assert.True(in4a[1] > 1);
            Assert.True(in4a[1] > 1);

            sbl3 = (StringBuilder)al2[1];
            Assert.Equal(sbl4.ToString(), sbl3.ToString());

            // 
            int p_inLoops0 = 2; 
            int p_inLoops1 = 2;
 
            al2 = new ArrayList();

            for (int aa = 0; aa < p_inLoops0; aa++)
            {
                al2.Capacity = 1;

                for (int bb = 0; bb < p_inLoops1; bb++)
                {
                    al2.Add("aa==" + aa + " ,bb==" + bb);
                }

                while (al2.Count > 0)
                {
                    al2.RemoveAt(0);
                }
            }

            Assert.Equal(0, al2.Count);
        }
        internal SoapParameters(XmlMembersMapping request, XmlMembersMapping response, string[] parameterOrder, CodeIdentifiers identifiers) {
            ArrayList requestList = new ArrayList();
            ArrayList responseList = new ArrayList();

            AddMappings(requestList, request);
            if (response != null) AddMappings(responseList, response);

            if (parameterOrder != null) {
                for (int i = 0; i < parameterOrder.Length; i++) {
                    string elementName = parameterOrder[i];
                    XmlMemberMapping requestMapping = FindMapping(requestList, elementName);
                    SoapParameter parameter = new SoapParameter();
                    if (requestMapping != null) {
                        if (RemoveByRefMapping(responseList, requestMapping))
                            parameter.codeFlags = CodeFlags.IsByRef;
                        parameter.mapping = requestMapping;
                        requestList.Remove(requestMapping);
                        AddParameter(parameter);
                    }
                    else {
                        XmlMemberMapping responseMapping = FindMapping(responseList, elementName);
                        if (responseMapping != null) {
                            parameter.codeFlags = CodeFlags.IsOut;
                            parameter.mapping = responseMapping;
                            responseList.Remove(responseMapping);
                            AddParameter(parameter);
                        }
                    }
                }
            }

            foreach (XmlMemberMapping requestMapping in requestList) {
                SoapParameter parameter = new SoapParameter();
                if (RemoveByRefMapping(responseList, requestMapping))
                    parameter.codeFlags = CodeFlags.IsByRef;
                parameter.mapping = requestMapping;
                AddParameter(parameter);
            }

            if (responseList.Count > 0) {
                if (!((XmlMemberMapping) responseList[0]).CheckSpecified) {
                    ret = (XmlMemberMapping)responseList[0];
                    responseList.RemoveAt(0);
                }
                foreach (XmlMemberMapping responseMapping in responseList) {
                    SoapParameter parameter = new SoapParameter();
                    parameter.mapping = responseMapping;
                    parameter.codeFlags = CodeFlags.IsOut;
                    AddParameter(parameter);
                }
            }

            foreach (SoapParameter parameter in parameters) {
                parameter.name = identifiers.MakeUnique(CodeIdentifier.MakeValid(parameter.mapping.MemberName));
            }
        }
		public override void GetContextMenuEntries(Mobile from, ArrayList list)
		{
			base.GetContextMenuEntries( from, list );

			for ( int i = 0; i < list.Count; ++i )
			{
				if ( list[i] is ContextMenus.PaperdollEntry )
					list.RemoveAt( i-- );
			}
		}
Example #26
0
File: Util.cs Project: langeds/aima
		public static ArrayList rest(ArrayList l) 
		{
			ArrayList newList = new ArrayList();
			foreach(object element in l)
			{
				newList.Add(element);
			}
			newList.RemoveAt(0);
			return newList;
		}
Example #27
0
        static void Main(string[] args)
        {
            // Array
            Console.WriteLine("Create an Array type collection of Animal objects and use it:");

            Animal[] animalArray = new Animal[2]; // Strongly typed
            Cow myCow1 = new Cow("Deirdre");
            animalArray[0] = myCow1;
            animalArray[1] = new Chicken("Ken");

            foreach (Animal myAnimal in animalArray)
            {
                Console.WriteLine("New {0} object added to Array collection, "
                    + "Name = {1}", myAnimal.ToString(), myAnimal.Name);
            }

            Console.WriteLine("Array collection {0} objects.", animalArray.Length);

            animalArray[0].Feed(); // invoke Animal method directly
            ((Chicken)animalArray[1]).LayEgg(); // cast to Chicken to invoke subclass method
            Console.WriteLine();

            // ArrayList
            Console.WriteLine("Create an ArrayList type collection of Animal "
                + "objects and se it:");

            ArrayList animalArrayList = new ArrayList(); // A collection of System.Objects
            Cow myCow2 = new Cow("Hayley");
            animalArrayList.Add(myCow2);
            animalArrayList.Add(new Chicken("Row"));

            foreach (Animal myAnimal in animalArrayList)
            {
                Console.WriteLine("New {0} object added to ArrayList collection,"
                    + " Name = {1}", myAnimal.ToString(), myAnimal.Name);
            }

            Console.WriteLine("ArrayList collection contains {0} objects.", animalArrayList.Count);
            ((Animal)animalArrayList[0]).Feed(); // cast to Animal
            ((Chicken)animalArrayList[1]).LayEgg(); // cast to Chicken to invoke subclass method
            Console.WriteLine();

            // Additional ArrayList manipulation
            Console.WriteLine("Additional manipulation of ArrayList:");
            animalArrayList.RemoveAt(0);
            ((Animal)animalArrayList[0]).Feed();
            animalArrayList.AddRange(animalArray);
            ((Chicken)animalArrayList[2]).LayEgg();

            Console.WriteLine("The animal called {0} is at index {1}.", myCow1.Name, animalArrayList.IndexOf(myCow1));
            myCow1.Name = "Janice";
            Console.WriteLine("The animal is now called {0}.", ((Animal)animalArrayList[1]).Name);

            Console.ReadKey();
        }
Example #28
0
        private ArrayList Loop(ref ArrayList inArray)
        {
            var subList = new ArrayList { inArray[0] };
            inArray.RemoveAt(0);

            int i = 0;
            while( i < inArray.Count)
            {
                if ((int)inArray[i] > (int)subList[subList.Count-1])
                {
                    subList.Add(inArray[i]);
                    inArray.RemoveAt(i);
                }
                else
                    i++;

            }

            return subList;
        }
Example #29
0
        private string DetermineLocalizedUrl()
        {
            ArrayList localeParts = new ArrayList(Page.UserCulture.Name.Split('-'));
            while (localeParts.Count > 0 && !FileExists(localeParts))
            {
                localeParts.RemoveAt(localeParts.Count - 1);
            }

            string locale = String.Join("-", (string[]) localeParts.ToArray(typeof(string)));
            return Page.ImagesRoot + (locale.Length > 0 ? "/" + locale : "") + "/" + this.ImageName;
        }
Example #30
0
 public static void FilterOutFixedWidthConnections(ArrayList connList)
 {
     for (int i = connList.Count - 1; i >= 0; i--)
     {
         ConnectionManager connManager = connList[i] as ConnectionManager;
         if (string.Compare("Delimited", (string)connManager.Properties["Format"].GetValue(connManager)) != 0)
         {
             connList.RemoveAt(i);
         }
     }
 }