🤔

CS0116#

A namespace cannot directly container members such as fields or methods

Resolution#

Do not put members of a type outside of its scope.

Scope is denoted by curly braces { }.

public class Example : MonoBehaviour
{ // <- The start of the class scope.

    // Inside the class scope.
    
} // <- The class scope has ended.

Example#

using UnityEngine;

// 🔴 Incorrect, do not place a member outside of the class scope.
public Transform Target;

public class Example : MonoBehaviour
{
    // 🟢 Correct, the member is inside of the Example class' scope.
    public Transform Target;
}

Example#

using UnityEngine;

namespace MyNamespace
{
    // 🔴 Incorrect, do not place a member outside of the class scope.
    public Transform Target;
    
    public class Example : MonoBehaviour
    {
        // 🟢 Correct, the member is inside of the Example class' scope.
        public Transform Target;
    }
}