Cannot make C# constructor compile [closed]
Whenever i try to apply my own constructor instead of the default one in VS 2010 I get the compiler error: Error 1 The namespace 'global namespace' already contains a definition for 'whatever'
Just as an example the compiler will not let me do this:
public class whatever
{
public whatever()
{
}
};
[Comments helped the OP solve the problem. Solution is here.]
The class is declared again in the same namespace in another file in your solution. Make sure that any such classes are renamed or removed, and everything should compile just fine.
In C# the class declaration and the definition are not separated (unlike C++) so you don't need a semi-colon after your class declaration.
edit
That error has nothing to do with the sem-colon, it was just something that jumped out at me. I would have to assume that your class was defined somewhere else in the same namespace. Is "whatever" really the name of the class you are trying to create?
精彩评论