Why this can't happen? properties {get; set;} x Structs

20 Views Asked by At

So, I've started learning C# and I'm in front of a problem. Why I can't use the properties {get; private set;} in this case?

private Vector2 _position; // Why it works to set _position? 
public Vector2 _position {get; private set;}; //In this second line, it warns me with a errorCS1612.  

My Main question is, Why I can't do like the second one example, since the first one do "the same thing" but with setters and getters methods? I read the CS1612 but I still didn't understand correctly.

Vector2 is a struct by the way and it all are in the same class so the access is the same.

0

There are 0 best solutions below