How can I fix my code under this text?
//puncts = puncts ?? new List<Vector2>() { new Vector2(position.X, position.Y) };
if (Vector2.Distance(position, puncts[indexpunkt] = puncts[indexpunkt] ?? new Vector2(position.X, position.Y) ) < 1)
indexpunkt++;
Error:
Error 1 Operator '??' cannot be applied to operands of type 'Microsoft.Xna.Framework.Vector2' and 'Microsoft.Xna.Framework.Vector2'
I wish create new puncts if it is null and add first element to its list.
Can I use operator ??
and how can I use it in if
statement?
Vector2
is aStruct
and therefore cannot be null, so coalescing operators don't apply.