I accidentally put two semi colon at the end of a statement while writing some code. I was amazed that it didn't gave any error. I mean what is the purpose of allowing double semi colon? What it actually means and how it can be useful at any particular programming method?
-
1`;;` means an empty statement. Empty statements are meaningless, but still treated as a correct code from the C# compiler – Ivaylo Slavov Dec 17 '14 at 11:03
-
http://stackoverflow.com/questions/2374569/c-sharp-empty-statement – David Heffernan Dec 17 '14 at 11:04
-
https://twitter.com/peterritchie/status/534011965132120064 ;) – Erti-Chris Eelmaa Dec 17 '14 at 11:04
2 Answers
Because ;
is just an empty statement in other words null statement. It's usually useless but completely valid.
This is used in loops where you want to perform something repeatedly but do not want to add a loop body.As shown in the below example:
for ( i = 0; i < 10; line[i++] = 0 )
;
In your case however, first semicolon is the end of the statement, second one is the empty statement.Which is useless and will be ignored by the compiler.

- 100,147
- 13
- 119
- 184
;;
is just the end of a statement, followed by an empty statement. Just like Oracle supports null;
. And other platforms do the same.
Sometimes you don't want to perform an action when you are supposed to according to the specs, like in a if
, while
, etc.
if (SomeAction())
;
else
SomethingElse();
Which of course should be written as:
if (!SomeAction())
SomethingElse();
It is probably easier to support ;;
as an statement end following an empty statement in general than support all the specific scenarios where you want to allow it.

- 97,721
- 20
- 209
- 280

- 153,850
- 22
- 249
- 325