- Home /
Question by
WillieZZy · Jul 07, 2010 at 01:59 AM ·
syntax-error
What is wrong with this C# code I have?
Here is the code, Unity is telling me that an identifier is expected, what ever that means I don't know. Here is the code:
void SwapArrayItem (nr1, nr2);{
var tmp=sortedHostList[nr1];
sortedHostList[nr1]=sortedHostList[nr2];
sortedHostList[nr2]=tmp;
}
I was in the process of converting JavaScript to C#, how do I make this completely C#?
Comment
Best Answer
Answer by Fanboy · Jul 07, 2010 at 02:22 AM
You need to declare the type for nr1 and nr2. For example:
void SwapArrayItem (int nr1, int nr2) {
int tmp=sortedHostList[nr1];
sortedHostList[nr1]=sortedHostList[nr2];
sortedHostList[nr2]=tmp;
}
And there is definitely no semicolon in the method header at all, either, which you missed.
Your answer
Follow this Question
Related Questions
how would i write this in C#? 1 Answer
split screen multiplayer car game? 2 Answers
java script error 2 Answers
Minus not working? 2 Answers
Another Error Accessing Components 1 Answer