Insert() public method

public Insert ( int index, Object value ) : void
index int
value Object
return void
Example #1
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);
 }
Example #2
0
        /// <summary>
        /// Deletes a List of Strings from the CSV File
        /// </summary>
        /// <param name="DeleteItems"></param>
        public void Delete(List<string> DeleteItems)
        {
            //SaveToFile
            try
            {
                ArrayList temp = new ArrayList();
                ///reads the file
                ///adds it to the array
                StreamReader inputStream = File.OpenText(oldLocal);
                string line;
                line = inputStream.ReadLine();
                for (int i = 0; line != null; i++)
                {
                    bool ignore = false;
                    foreach (string deleteItem in DeleteItems)
                    {
                        string[] breakUp = line.Split(',');
                        string itemName = breakUp[0] + "/" + breakUp[3];
                        if (itemName.CompareTo(deleteItem) == 0)
                        {
                            try
                            {
                                File.Delete(breakUp[4]);
                                temp.Insert(i, "");
                                ignore = true;
                                break;
                            }
                            catch
                            {
                                MessageBox.Show("File :" + breakUp[0] + " " + breakUp[3] + " is in use. Close file before deleting");
                            }

                        }
                    }
                    if (!ignore)
                    {
                        temp.Insert(i, line);
                    }
                    line = inputStream.ReadLine();
                }
                inputStream.Close();

                StreamWriter outputStream = File.CreateText(oldLocal);
                for (int g = 0; g < temp.Count; g++)
                {
                    if (temp[g] != null && temp[g] != "")
                    {
                        outputStream.WriteLine(temp[g]);
                    }
                }
                outputStream.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show("CSV ERROR: " + e);
            }
        }
        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();
        }
 public TinhBieuThuc(string input)
 {
     PhepTinh = new PhepTinh();
     BieuThuc = new ArrayList();
     input = input.Replace(" ", "") + ")";
     string temp = "";
     int tag = 0;
     while (input != "") {
         bool isDigit = isNumber(input[0])
             ||
             (tag == 0 && input[0] == '-' && char.IsDigit(input[1]));
         if (isDigit) {
             tag = 1;
             do {
                 temp += input[0].ToString();
                 input = input.Substring(1);
             } while (isNumber(input[0]) && input[0] != '-');
             BieuThuc.Add(double.Parse(temp));
             temp = "";
         }
         else {
             tag = 0;
             BieuThuc.Add(input[0].ToString());
             input = input.Substring(1);
         }
     }
     for (int i = 0; i < BieuThuc.Count - 1; i++) {
         if (isDouble(BieuThuc[i]) && isDouble(BieuThuc[i + 1])) {
             BieuThuc.Insert(i + 1, "+");
         }
     }
 }
        public void InsertUpdateEvent(ArrayList Event)
        {

            CRM.DataAccess.AdministratorEntity.EventStoredProcedure objinsertevent = new CRM.DataAccess.AdministratorEntity.EventStoredProcedure();
            Event.Insert(3, Session["usersid"].ToString());
            objinsertevent.InsertUpdateEventMaster(Event);
        }
        public void InsertUpdateAgentName(ArrayList Agent)
        {

            AgentMasterStoredProcedure objagent = new AgentMasterStoredProcedure();
            Agent.Insert(13, Session["usersid"].ToString());
            objagent.InsertUpdateAgentName(Agent);
        }
Example #7
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 void InsertUpdateProfileInfo(ArrayList Profile)
        {
            UserProfileStoredProcedure objeditprofile = new UserProfileStoredProcedure();
            Profile.Insert(14, Session["usersid"].ToString());
            objeditprofile.InsertUpdateProfileInfo(Profile);

        }
        public void InsertUpdateFromMaster(ArrayList From)
        {

            CRM.DataAccess.AdministratorEntity.FromMasterStoredProcedure objfrom = new CRM.DataAccess.AdministratorEntity.FromMasterStoredProcedure();
            From.Insert(3, Session["usersid"].ToString());
            objfrom.InsertUpdateFromMaster(From);
        }
        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();
        }
        public void InsertUpdateEmailConfig(ArrayList Config)
        {

            CRM.DataAccess.AdministratorEntity.EmailConfigStoredProcedure objemailConfig = new CRM.DataAccess.AdministratorEntity.EmailConfigStoredProcedure();
            Config.Insert(5, Session["usersid"].ToString());
            objemailConfig.InsertUpdateEmailConfig(Config);
        }
Example #12
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     if (SubjectBox.Text.Length == 0)
     {
         MessageBox.Show("Cannot proceed with empty name");
         return;
     }
     ArrayList list = new ArrayList((string[])Host.SubjectList.DataSource);
     list.Sort();
     int id = list.BinarySearch(SubjectBox.Text);
     if (id >= 0)
     {
         MessageBox.Show("Subject with that name already exists!");
         return;
     }
     id = ~id;
     list.Insert(id, SubjectBox.Text);
     string[] n = new string[list.Count];
     list.CopyTo(n);
     Host.SubjectBox2.AutoCompleteCustomSource.Add(SubjectBox.Text);
     Host.SubjectList.DataSource = n;
     Host.RenewSubjectList();
     Host.SubjectList.SelectedItem = SubjectBox.Text;
     this.Close();
 }
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
        protected virtual ArrayList AddCheckBoxColumn(ICollection columnList)
        {
            ArrayList list = new ArrayList(columnList);

            // Determine the check state for the header checkbox
            string shouldCheck = "";
            string checkBoxID = String.Format(CheckBoxColumHeaderID, ClientID);
            string checkBoxName = String.Format(CheckBoxColumHeaderName, UniqueID);

            if (IsTitleCheckBoxChecked)
                shouldCheck = "checked=\"checked\"";

            // Create a new custom CheckBoxField object
            InputCheckBoxField field = new InputCheckBoxField(RowIdPropertyName);
            field.ItemStyle.Width = new Unit("16px");
            field.HeaderText = String.Format(CheckBoxColumHeaderTemplate, checkBoxID, checkBoxName, shouldCheck, ClientJSObjectName);
            field.ReadOnly = true;

            // Insert the checkbox field into the list at the specified position
            if (CheckBoxColumnIndex > list.Count)
            {
                // If the desired position exceeds the number of columns
                // add the checkbox field to the right. Note that this check
                // can only be made here because only now we know exactly HOW
                // MANY columns we're going to have. Checking Columns.Count in the
                // property setter doesn't work if columns are auto-generated
                list.Add(field);
                CheckBoxColumnIndex = list.Count - 1;
            }
            else
                list.Insert(CheckBoxColumnIndex, field);

            // Return the new list
            return list;
        }
        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());
            }
        }
        public void InsertUpdateProfessionName(ArrayList Prof)
        {

            ProfessionMasterStoredProcedure objprof = new ProfessionMasterStoredProcedure();
            Prof.Insert(2, Session["usersid"].ToString());
            objprof.InsertUpdateProfessionName(Prof);
        }
        public void InsertUpdateTargetList(ArrayList Target)
        {

            TargetListStoredProcedure objinserttarget = new TargetListStoredProcedure();
            Target.Insert(7, Session["usersid"].ToString());
            objinserttarget.InsertUpdateTargetList(Target);
        }
        private void ArrayListTest()
        {
            ArrayList list = new ArrayList();
             list.AddRange(
            new Car[]
               {
                  CAR_BANK[0],
                  CAR_BANK[1],
                  CAR_BANK[2]
               });
             Console.WriteLine("Number of cars = {0}", list.Count);

             foreach ( Car car in list )
            car.Display();
             Console.WriteLine();

             list.Insert( 2, CAR_BANK[3] );

             foreach (Car car in list)
            car.Display();
             Console.WriteLine();

             list[0] = CAR_BANK[4];

             foreach (Car car in list)
            car.Display();
        }
Example #19
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);
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Load Protal Definition and the current Tab
            PortalDefinition pd = PortalDefinition.Load();
            PortalDefinition.Tab currentTab = pd.GetTab(Request["TabRef"]);

            // Great, we are a top level Tab
            if(currentTab.parent == null) return;

            ArrayList tabList = new ArrayList();
            while(currentTab != null)
            {
                DisplayTabItem dt = new DisplayTabItem();
                tabList.Insert(0, dt);

                dt.m_Text = currentTab.title;
                dt.m_URL = Portal.API.Config.GetTabURL(currentTab.reference);

                // one up...
                currentTab = currentTab.parent;
            }

            // Bind Repeater
            tabpath.DataSource = tabList;
            tabpath.DataBind();
        }
Example #21
0
        private string Breaker(ArrayList Cell_String)
        {
            for (int i = 1; i < Cell_String.Count; i++)
            {
                if (Fun_Class.IsFunction(Cell_String[i].ToString()))
                {
                    int found = 1;
                    int start = i + 1;

                    while (found != 0)
                    {
                        start++;
                        if (Cell_String[start].ToString().Equals("("))
                            found++;
                        if (Cell_String[start].ToString().Equals(")"))
                            found--;
                    }
                    ArrayList atemp = new ArrayList(Cell_String.GetRange(i, start - i + 1));
                    Cell_String.RemoveRange(i, start - i + 1);
                    Cell_String.Insert(i, Breaker(atemp));
                }
            }

            //PrintArrayList(Cell_String);
            //System.Console.WriteLine(Cell_String[0].ToString());

            return Fun_Class.CallFunction(Cell_String);
        }
Example #22
0
 public static void Choose(string source, ArrayList Al_r, ArrayList Al_h, int[] Points)
 {
     int nums = 0;
     int totalNums = 0;
     StreamWriter sw = new StreamWriter(source, false, System.Text.Encoding.Default);
     foreach (Object o in Al_r)
     {
         Al_h.Insert(0, o.ToString());
     }
     for (int i = 0; i < Points.Length; i++)
     {
         sw.WriteLine(Points[i] + " : ");
         for (int j = Al_h.Count - 1; j >= 0; j -- )
         {
             if (j % Points[i] == 0)
             {
                 sw.WriteLine(Al_h[j].ToString().Substring(6));
                 nums += 1;
             }
         }
         sw.WriteLine("条数 : " + nums);
         sw.WriteLine();
         totalNums += nums;
         nums = 0;
     }
     sw.WriteLine();
     sw.WriteLine("总条数 : " + totalNums);
     sw.Close();
 }
        public void InsertUpdateBankName(ArrayList bank)
        {

            BankMasterStoredProcedure objbank = new BankMasterStoredProcedure();
            bank.Insert(2, Session["usersid"].ToString());
            objbank.InsertUpdateBankName(bank);
        }
Example #24
0
        protected void myGrid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.DataRow)
            {
                return;
            }
            DropDownList myDropdown = (DropDownList)e.Row.FindControl("myDropdown");
               //  List<Customer> customerList = new List<Customer>(){
               //      new Customer(){Name="jambor" ,Age="1"},
               //      new Customer(){Name="yao" ,Age="1"},
               //};
            //myDropdown.DataSource = ArrayList;
            //myDropdown.DataTextField = "Name";
            //myDropdown.DataValueField = "Age";
            //myDropdown.DataBind();
            ArrayList list = new ArrayList();
            list.Add("none");
            list.Add("Canada Post");
            list.Add("UPS");

            list.Insert(1, "FedEx");

            myDropdown.DataSource = list;
            myDropdown.DataBind();
        }
         public void InsertUpdatecoachtype(ArrayList Coach)
         {

             CoachMaster objcoachtype = new CoachMaster();
             Coach.Insert(3, Session["usersid"].ToString());
             objcoachtype.InsertUpdatecoachtype(Coach);

         }
        public void InsertUpdateCustomerType(ArrayList Ctype)
        {

            CustomerTypeStoredProcedure objctype = new CustomerTypeStoredProcedure();
            Ctype.Insert(3, Session["usersid"].ToString());
            objctype.InsertUpdateCustomerType(Ctype);

        }
        public void InsertUpdateForeignCurrencyAgent(ArrayList CurrencyAgent)
        {

            ForeignCurrencyAgentStoredProcedure objCurrencyAgent = new ForeignCurrencyAgentStoredProcedure();
            CurrencyAgent.Insert(6, Session["usersid"].ToString());
            objCurrencyAgent.InsertUpdateForeignCurrencyAgent(CurrencyAgent);

        }
        public void InsertUpdateSupplierBankAccount(ArrayList SupplierAccount)
        {

            CRM.DataAccess.AdministratorEntity.SupplierBankAccountStoredProcedure objinsertbankdetail = new CRM.DataAccess.AdministratorEntity.SupplierBankAccountStoredProcedure();
            SupplierAccount.Insert(9, Session["usersid"].ToString());
            objinsertbankdetail.InsertUpdateSupplierBank(SupplierAccount);

        }
        public void InsertUpdateProductName(ArrayList Product)
        {

            ProductMasterStoredProcedure objproductname = new ProductMasterStoredProcedure();
            Product.Insert(2, Session["usersid"].ToString());
            objproductname.InsertUpdateProductName(Product);

        }
        public void InsertUpdateAgent(ArrayList agent)
        {

           CRM.DataAccess.AdministratorEntity.AgentCommisionMaster objagent = new CRM.DataAccess.AdministratorEntity.AgentCommisionMaster();
            agent.Insert(5, Session["usersid"].ToString());
           objagent.InsertUpdateAgentcommision(agent);
             
        }