Ok, let's simplify it a little bit:
HoweverCode:Bitmap MyBitmap = new Bitmap(100,50); object MyVariableHolder = MyBitmap; MyBitmap.Height = 200; Console.WriteLine(MyBitmap.Height); Console.WriteLine(((Bitmap)MyVariableHolder).Height); results in: 200 200
I understand what causes this, but I don't know, how to modify MyString to force MyVariableHolder to keep the reference and thus, return "new string".Code:string MyString = "old string"; object MyVariableHolder = MyString; MyString = "new string"; Console.WriteLine(MyString); Console.WriteLine((string)MyVariableHolder); results in: new string old string




Reply With Quote