Statement Termination

Statement Termination

In C#, a statement is terminated by a semicolon (;) at the end of the line. The semicolon is used to indicate the end of the statement and tell the compiler to move on to the next line of code.

Here’s an example of a statement terminated by a semicolon:

int x = 10;

In this example, the statement declares a variable “x” and assigns it the value of 10. The semicolon at the end of the line indicates the end of the statement.

It’s important to remember to include the semicolon at the end of each statement in C#. If you forget to add a semicolon, the compiler will raise an error.

Here’s an example of what happens when you forget to include a semicolon:

int x = 10

int y = 20;

In this example, the first line of code is missing a semicolon. When you try to compile this code, the compiler will raise an error and tell you that a semicolon is expected. So, remember to always terminate your statements with a semicolon to avoid errors and ensure that your code compiles correctly.

Apply for ASP.NET Certification Now!!

https://www.vskills.in/certification/certified-aspnet-programmer

Back to Tutorial

Technical Writing Glossary
Blocks

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?