Scripting Errors

Ok, I lost some time with this although it seems very easy. I attached a screenshot.

The code seems correct and at first it would not run in Unity due to scripting errors. Then, after going over the code time and again, it suddenly works in Unity but still gives errors in Visual Studio. What am I missing?