I am just curious to know why this is allowed.
int i=0;;
I accidentaly typed that. But the program compiled. I noticed it after many days that I have typed ;;
After that I tried with different symbols like ~, !, : etc etc
Why is that not allowed where as first one is allowed.
Just curious to know.
You have typed an empty statement:
int i=0; // that's one statement
; // that's another
It's legal for an statement in C# to have no body.
From section 8.3 of the C# Language Specification:
An empty-statement does nothing.
empty-statement:
;
An empty statement is used when there are no operations to perform in a context where a statement is required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With