I'm having strange issue where I am creating a new object which contains a parameter for another object (paramObj) I use through my function. So, paramObj is used in an object constructor, but it ends up being altered after the constructor is called. Since C# is pass by value, I'm not sure why this is happening.
My code:
void MyFunction(List<string> filesets)
{
foreach(Fileset fs in filesets)
{
//At this point, fs.allFiles.Count is 30. The MyNewObject class
//takes a Fileset as a parameters and eventually clears the
//Fileset.allFiles List, making the count 0.
MyNewObject tmpObj = new MyNewObject(fs, null, "default");
//At this point, fs.allFiles.Count is 0, but I expect it to be 30
}
}
The MyNewObject
class simply clears the allFiles
list contained within a Fileset
class. Why is that showing up after the constructor if C# is pass by value?