R
Ralf B.
Hi everybody
I feel kind of dumb for not finding anything useful to point me in the right
direction..
basically, I want to create a class with an Arraylist. I would like to add
strings and integers etc.
as referenced objects. Once all items are added I want to loop through the
ArrayList and
manipulate all items depending on their type which, once i get it working
will save a lot of coding.
the class is looks kind of like this (simplified)
public MyClass
{
private ArrayList items = new ArrayList();
public void AddItem(ref object item); // other parameters skipped for
post
{
items.Add(item);
}
public void Execute()
foreach (object obj in items)
{
if (obj is string)
obj = "my string value";
}
}
... main code
MyClass myClass = new MyClass();
myClass.AddItem((object) myString);
......
The code compiles and runs just fine with the annoying exception that
myString does not receive the new
value 'my string value'. I am sure it is something absolutely simple but I
am just looking at a black wall
Any help would be greatly appreciated.
Thanks
rb
I feel kind of dumb for not finding anything useful to point me in the right
direction..
basically, I want to create a class with an Arraylist. I would like to add
strings and integers etc.
as referenced objects. Once all items are added I want to loop through the
ArrayList and
manipulate all items depending on their type which, once i get it working
will save a lot of coding.
the class is looks kind of like this (simplified)
public MyClass
{
private ArrayList items = new ArrayList();
public void AddItem(ref object item); // other parameters skipped for
post
{
items.Add(item);
}
public void Execute()
foreach (object obj in items)
{
if (obj is string)
obj = "my string value";
}
}
... main code
MyClass myClass = new MyClass();
myClass.AddItem((object) myString);
......
The code compiles and runs just fine with the annoying exception that
myString does not receive the new
value 'my string value'. I am sure it is something absolutely simple but I
am just looking at a black wall
Any help would be greatly appreciated.
Thanks
rb