1

I tried to call a sample function, written in c# in Unity Environment. I get this error message:

Multi member names can not be the same as their enclosing type

This is the code I am using:

using UnityEngine;
using System.Collections;

public class multi : MonoBehaviour {
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        int x = 5;
        multi (x);
    }

    int multi ( int tem ){
        int ret ;
        ret = tem * 2 ; 
        return ret;
    }
}

2 Answers 2

10

A function name cannot be the same as the class name, unless the function is a constructor.

0
6

You can't have a function "multi" in a class named "multi" unless it's a constructor.

1
  • 1
    You beat me too it! Almost identical responses.
    – Smeegs
    Mar 17, 2014 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.