C# .NET - change Value in ArrayList in ArrayList

Asked By Nattachai Boonkam
02-Jan-06 11:42 PM
pls help me

                ArrayList arrContain = new ArrayList();
			
	ArrayList data = new ArrayList();

	data.Add("a");
	data.Add("b");
	data.Add("c");
	data.Add("d");
	arrContain.Add(data);
			
	data = new ArrayList();
	data.Add("aa");
	data.Add("bb");
	data.Add("cc");
	data.Add("dd");
	data.Add("ee");
	arrContain.Add(data);
			
	data = new ArrayList();
	data.Add("11");
	data.Add("22");
	data.Add("33");
	data.Add("44");
	data.Add("55");
	data.Add("66");
	arrContain.Add(data);

i want to change VALUE in array in array
for example i want to change "66" to "666",change "dd" to "dddd"
            
last time i use

foreach(ArrayList arrContain in arrContain)
{
	int size = arrTemp.Count;
	show = arrTemp[size-1].ToString();
	data = new ArrayList();
	count += "   "+arrContain.Count.ToString();
	//int index = arrContain.IndexOf(arrTemp.Count-1);
	//countaa += index+"  ";
				
	if(show=="66")
	{	
	         int index = arrTemp.IndexOf(show);
	
	         arrContain.RemoveAt(index);
	         arrContain.Insert(index,"666");
//2//	         arrContain[size-1] = "666"; 
                }

}
but it useless

help me pls

thank you very very much

Code  Code

03-Jan-06 01:41 PM
Hi Nattachai,

You have to perform 2 loops to accomplish this.  Try this:

foreach (ArrayList arr1 in arrContain) {
foreach (string arrValue in arr1) {
if (arrValue == "66")
arrValue = "666";

if (arrValue == "dd")
arrValue = "ddd";
}
}

Cannot assign to 'arrValue' because it is read-on  Cannot assign to 'arrValue' because it is read-on

03-Jan-06 02:04 PM
thank you,Ronald Francisco
but Cannot assign to 'arrValue' because it is read-only
Create New Account
help
ArrayList Remove Item .NET Framework Hi ALL I have create ArrayList Object, I want to loop to remove someitem in the ArrayList. However, it pops me exception. The example is foreach(string s in arraylist){ if(s.Equals("test")) arraylist.Remove(s); } when it removes one item and do the next loop, it will pops is from last to the first? Does it sound silly? Thanks .NET Compact Framework Discussions ArrayList (1) IndexOf (1) RemoveAt (1) Remove (1) Contains (1) Equals (1) When you remove an item, the item indexer
how to merge 2 arraylist with removing duplicate values in vb.net end of post rounding off value in vb.net 2005 At first place, i would suggest you to use the ArrayList.Contains Method to prevent adding of duplicates. However, the below code snippet would remove duplicates from an Arraylist Dim pos As Integer = 0 Do Until pos = arrList.Count Dim iCurrentItem As Integer For 1 To pos + 1 Step -1 If arrList(pos).ToString = arrList(i).ToString Then arrList.RemoveAt(i) End If Next pos + = 1 Loop u need to first add one arraylist to another and then remove duplicate form that arraylist Try this: public void RemoveDuplicates(ref int[] A) { Array.Sort(A ArrayList list = new ArrayList(A); for (int i = list.Count - 1; i > 0; i- -) { if ((int)list[i] = = (int
ArrayList with Listbox hi every one, I am having a listbox where I am storing the which the user select from a grid view along with that I am having a ArrayList object which stores the price of the irems selected by the user but the problem to remove the item from a list box I want that corresponding price from a ArrayList object should be removed the code which I have written for removing the item and btnremove_Click( object sender, ImageClickEventArgs e) { while (ListBox1.SelectedItem ! = null ) { ListBox1.Items.Remove(ListBox1.SelectedItem); alprice.RemoveAt(ListBox1.SelectedIndex); } } I am not getting how to remove the value from a arraylist please help thanks in advance There is nothing wrong with your code, provided that alprice S. You probably need to re-bind the ListBox after removing the item from the arraylist, e.g. alprice.RemoveAt(ListBox1.SelectedIndex); ListBox1.DataSource = alprice; ListBox1.DataBind(); Make sure the listbox and arraylist is only loaded the first time the page loads and not reloaded with the default
zuerst die inahlte einer bestimmten spalte in eine arrayliste schreiben. das versuche ich wie folgt: ArrayList FCOIDs = new ArrayList(); for (int i = 0; i < DTable_FCO.Rows.Count; i++) { for (int x = 0; x < DTable_FCO.Columns.Count; x++) { if(DTable_FCO.Columns.IndexOf("FZG-ID") > 0) { FCOIDs.Add(DTable_FCO[x, i]); } } } leider kommt bei: FCOIDs.Add(DTable_FCO[x zugreifen kann. kann mir jemand helfen ? C# - German Discussions DataColumnCollection (1) ReadAllLines (1) DataColumn (1) ArrayList (1) DataTable (1) DataRow (1) FCOIDs (1) LINQ (1) Hallo, wir benutzen hier gerne den erst mal nur den offensichtlichen Fehler beseitigt. Also folgendes ist sicher falsch: if(DTable_FCO.Columns.IndexOf("FZG-ID") > 0) IndexOf gibt im Framework normal immer -1 zur = FCck, wenn das Element nicht gefunden wird: [DataColumnCollection.IndexOf-Methode (DataColumn) (System.Data)] http: / / msdn.microsoft.com / de-de / library / 1dd8zxxb.aspx Du musst lese ich zuerst textdateien ein, die die daten enthalten. die dateinamen schreibe ich in eine arraylist. danach lese ich die erste textdatei ein und ermittle aus der ersten zeile die spaltennamen