In my unity project I have a grid which I coded the columns and rows like this:
public int rows = 10;
public int columns = 10;
But then when i try to set the value of another variable like this:
Total = columns * rows;
It gives me the following errors:
A field initializer cannot reference the non-static field, method, or property 'Enemy.rows'
A field initializer cannot reference the non-static field, method, or property 'Enemy.columns'
However it does work if I use => instead of = and I wanted to know why. The only thing I can think of is because the values of columns and rows can change. I know => is a getter but I don't understand much about it as I am new to unity/c#.