class Tubo { bool value; bool TuboTubo() { return value; } }
Will this piece of code compile (answer without compiling, please )?
class Tubo { bool value; bool TuboTubo() { return value; } }
Will this piece of code compile (answer without compiling, please )?
3 replies on “Assigning default values to fields trivia”
yes. cuz the variable is declared on class level and will be initialized automatically.
Questions like this are always difficult to answer without understanding of how language is supposed to behave.
I think, this should raise compiler error for “use of unassigned variable”
Giuseppe got it right. This time the field is set to its default value.
@Kalpesh: otoh it is fun and we all learn 🙂