Ktoto
Ktoto
CC#
Created by Ktoto on 11/30/2024 in #help
Y it doubles on adding?
I have a code like this
c#
a += b;
c#
a += b;
I have overloaded operator +. T is class with list & a lot's of readonly fields depending on this list. b is always small, something like ~0.001 and on adding elements become 2 limes larger. When i debug it, it works normal. Here is code of operator:
c#
class T
{
List<float> list;
public static T operator +(T a, T b)
{
T result = a;
for (int i = 0; i < a.list.Count; i++)
{
result.list[i] += b.list[i];
}
return result;
}
}
c#
class T
{
List<float> list;
public static T operator +(T a, T b)
{
T result = a;
for (int i = 0; i < a.list.Count; i++)
{
result.list[i] += b.list[i];
}
return result;
}
}
55 replies