public int NewHighscoreTable(string strDefaultName, long lDefaultScore, long lDefaultLowerScore)
{
FileStream fs = File.Create("highscore.dat");
struct highscoreLine
{
public string strName;
public int iScore;
}
highscoreLine hl = new highscoreLine();
return 0;
}
C# using structs
Hello,
I'm rather new to the C# language, but I know C++.
Now I came upon a problem when using a struct and I can't seem to figure it out for the moment :
I want to create a highscore table (I just started writing the code, so I do not have much for now).
When I execute this code I get the following errors :
Error 1 } expected => points to the semicolon (;) right after the FileStream line
Error 2 Invalid token 'return' in class, struct, or interface member declaration
Error 3 Type or namespace definition, or end-of-file expected
When I comment out the whole struct lines, then the errors are gone and I can execute my code with no problem.
Am I missing something here?!?
Maybe try to declare the struct outside of the method?
I'm not sure if you can declare a struct/class inside a method (that is, a local struct/class). You can in C++, but I don't know about C#.
I'm not sure if you can declare a struct/class inside a method (that is, a local struct/class). You can in C++, but I don't know about C#.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement