- Home /
Crash when using "Base" as member... is it a reserved word ?
Hello,
I am encountering today a quite bizarre issue, and also quite specific.
When using "Base" as member name (Base being a Serializable class) within a Singleton (using the classic c# singleton implementation), Unity crashes (when saving/loading the scene).
I know "base" is a reserved word, but is "Base" as well? What am I missing ?
To reproduce:
create a Singleton
in this singleton, create a "public TestClass Base;"
TestClass is defined as:
[System.Serializable] public class testclass { public int stuff; }
Notes:
No crash if with another member name (such as "TheBase")
No crash outside of a Singleton either (although the Singleton doesn't use any "Base")
No crash if Base is defined as an int (for instance) rather than a Serializable custom class
Thanks
Answer by Cherno · Jul 06, 2015 at 09:42 AM
A quick google search only brought up the word "base" as a keyword.
Yes, "base" (low case) is a reserved word in c# for sure.
I can't find the correlation with "Base" (PascalCase) though... and crashing only in this specific conditions.
Can't speak to the reason for this specific issue; there are several magic words you can't or probably shouldn't use in any language / API. An alternate capitalization of a keyword definitely falls into the later category; evidently, in this case, the former as well.
Still, I would have expected something to catch the issue (auto completion, compiling error or warning...), be less intricate in the repro steps, not to mention the IDE crash...
Leaving this here, if anyone has a suggestion for this mystery.
Your answer
![](https://koobas.hobune.stream/wayback/20220611230002im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Game doesnt start after adding Admob 1 Answer
Singleton implementation 1 Answer
Where would I call the DoDestroyOnLoad function on my Singleton Script 1 Answer