Automatic initalising of variables in C#?

In Levels.cs we only declare the variable breakableBlocks but we don’t initialise it.

Does that mean we can count on C# to always initialise an integer to zero when we declare it?

Hi Frank,

You are right. In C#, all variables get initialised automatically with a default value if you do not initialise a variable yourself. For int, it’s 0; for float 0f, etc.


See also:

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms