Search Unity

Need Help with Fixing Errors

Discussion in 'Scripting' started by redman76, May 28, 2018.

  1. redman76

    redman76

    Joined:
    May 28, 2018
    Posts:
    1
    Hey all, I am a beginner in coding. I encountered a few errors that I can't seem to fix.



    Line 28 and Line 33 says, "Feature 'local functions' is not available in C# 4. Please use language version 7.0 or greater."
    I tried fixing this by installing Microsoft.Net.Compilers as shown when I look the error up, but I still have these problems.
    Line 24 says I need a definition when I thought I added one?
    Line 25 says cannot convert object to int. I have no clue on that one.
     

    Attached Files:

  2. Prastiwar

    Prastiwar

    Joined:
    Jul 29, 2017
    Posts:
    125
    Put your code in code tags in forum, don't send file. https://forum.unity.com/threads/using-code-tags-properly.143875/

    You have big problems with brackets, here you are short tutorial:

    Example of correct code structure
    Code (CSharp):
    1. public class NameOfClass
    2. { // starts class's block
    3.  
    4.     void Method() // declare method
    5.     { // starts Method's block
    6.           foreach(var item in collection)
    7.           { // starts foreach loop block
    8.                // code
    9.           } // ends foreach loop block
    10.     } // ends Method's block
    11.  
    12.    void SecondMethod() // declare second method
    13.    { // starts SecondMethod's block
    14.        //code
    15.    } // ends SecondMethod's block
    16.  
    17. } // ends class's block
    You can't do something like this.
    Code (CSharp):
    1. public class NameOfClass
    2. { // starts class's block
    3.  
    4.     void Method() // declare method
    5.     { // starts Method's block
    6.         void SecondMethod() // declare method in method
    7.         { // starts SecondMethod's block
    8.              foreach(var item in collection) { } // inlined start and end foreach loop
    9.              item.ToString() // you are outside loop
    10.         } // ends SecondMethod's block
    11.     } // ends Method's block
    12.  
    13. } // ends class's block