gpt4 book ai didi

c# - 只有赋值调用 increment decrement 和 new object expressions 可以用作语句

转载 作者:太空宇宙 更新时间:2023-11-03 21:09:43 24 4
gpt4 key购买 nike

我正在使用 Unity 制作游戏,我不知道为什么会收到此错误。如果你们能帮助我,我将不胜感激。

private enum States
{
NewGame,
Cell,
Sheets,
Mirror,
Lock,
Key,
Escape
}

private States my_state;

void state_cell()
{
text.text = "You are in a jail captured by Indians, you have to escape at all cost. You have to " +
"aware the Pakistan Army about the evil plans of indians, and you got minimal time left " +
"\n\n Press S to view the Sheets, press R to return, Press M to get the Mirror,press " +
"L to view the Lock, and press M to make Key";
if(Input.GetKeyDown(KeyCode.S))
{
(my_state = States.Sheets);
}
}
void state_sheets()
{
text.text = "Press S to view the sheets which has info about the security lock, There is some wet " +
"mud and a metal things lying around see if you can make a key for the Lock " +
"Also you wanna cut some piece from the Mirror hanging on the wall to find the " +
"measurements of the Lock";

if(Input.GetKeyDown(KeyCode.R))
{
(my_state = States.Cell);
}
}

另外我正在使用 monodevelop 版本 4.0.1

最佳答案

你这里的括号是无用的,会导致编译器错误:

(my_state = States.Sheets);

这样做会:

my_state = States.Sheets;

只有在一些情况下才允许使用括号,例如 if ()((CastTo)a) 语句。这不是其中一种情况:不要在赋值周围加上括号。

关于c# - 只有赋值调用 increment decrement 和 new object expressions 可以用作语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38499925/

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