class Tubo { bool value; bool TuboTubo() { return value; } }
Will this piece of code compile (answer without compiling, please )?
About .NET/C#, Xamarin, Flutter and other fun technologies
class Tubo { bool value; bool TuboTubo() { return value; } }
Will this piece of code compile (answer without compiling, please )?
You must be logged in to post a comment.
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 🙂