Hi!
I noticed a very funny behaviour when overloading operators
on objects in C#:
MyOjbects a,b,c,d;
....
//objects are created and initalized here...
....
b.Length = 100;
c.Length = 100;
for (i = 0; i < 10000; i++)
{
a = MyFun(2*c)*b;
}
Inside the overladed multiplication operator, I check:
if (Op1.Length == Op2.Length) throw....
And the exception triggers after about 100 iterations...!! ?
Somehow the internal objects of the temporary variable
created by 2*c passed to MyFun are being
garbage collected (nullified) before the temporary variable is used for
the first time...
Are there some known issues with this?
Thanks!
Atmapuri
I noticed a very funny behaviour when overloading operators
on objects in C#:
MyOjbects a,b,c,d;
....
//objects are created and initalized here...
....
b.Length = 100;
c.Length = 100;
for (i = 0; i < 10000; i++)
{
a = MyFun(2*c)*b;
}
Inside the overladed multiplication operator, I check:
if (Op1.Length == Op2.Length) throw....
And the exception triggers after about 100 iterations...!! ?
Somehow the internal objects of the temporary variable
created by 2*c passed to MyFun are being
garbage collected (nullified) before the temporary variable is used for
the first time...
Are there some known issues with this?
Thanks!
Atmapuri
Comment