Say if I have a collection of objects called MyObjects.
Now I am looping on the above collection and adding it to another object called MyObject2. MyObjects has a property called ‘files’.
I want to manipulate the value of files property when I am looping around my first collection. first of all can I do as code shown below. If yes, I get an error as follow :
{Cannot evaluate expression because the current thread is in a stack overflow state.}
List<objects> MyObjects = Populate();
List<objects> MyObject2 = new List<objects>();
foreach(var item in MyObjects)
{
item.files = "test file" + item.files;
MyObject2.add(item);
}
edit ::
files property:
[Transient]
protected string _files;
public string files
{
get
{
return _files;
}
set
{
_files= value;
}
}
Psychic debugging – I suspect your
filesproperty looks something like this:That will just recurse forever until the stack blows up. That’s just guesswork though, as you haven’t shown us the crucial piece of code.