When do you use semicolon in C# and why?
Experience Level: Junior
Tags: C#
Answer
In C# there can are two kinds of statements.
- Simple single line statements - this kind of statement requires a semicolon at the end of a statement. Thanks to this you can use multiple simple statements on the same line.
- Compount statements (block statements) - this kind of statement is enclosed in {} brackets and for that reason doesn't need a semicolon at the end of a statement as the end of a statement is marked by the closing curly bracket.
The semicolon isn't the line terminator. It's the statement terminator.
Related C# job interview questions
What is a method parameter in C#?
C# JuniorWhat is a method return type in C#?
C# JuniorWhat is an instance method in C#?
C# JuniorWhat is a static method in C#?
C# JuniorHow can you find out what is the variable type?
C# Junior
Chat
Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.
Anonymous
Καλησπέρα.
Καλησπέρα.
Anonymous
the infinteis -3/15 so 1triition / infinet
the infinteis -3/15 so 1triition / infinet
Anonymous
e
e
Anonymous
<a href="https://inspirum.pl "
<a href="https://inspirum.pl "
Anonymous
[url]https://inspirum.pl[/url]
[url]https://inspirum.pl[/url]
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e
LaceJaguar65
e
e