gpt4 book ai didi

c# - 调用函数的错误是什么?

转载 作者:太空宇宙 更新时间:2023-11-03 17:13:23 25 4
gpt4 key购买 nike

我尝试调用一个示例函数,该函数是在 Unity 环境中用 c# 编写的。我收到此错误消息:

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

这是我使用的代码:

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;
}
}

最佳答案

函数名不能与类名相同,除非该函数是构造函数。

关于c# - 调用函数的错误是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22464923/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com