C# Syntax

C# Syntax

C# syntax defines how C# programs are written and structured. It is clean, readable, and similar to Java and C++.


 Basic Structure of a C# Program


 


 Key Syntax Rules

1. Case Sensitivity

C# is case-sensitive.


 2. Statements End with Semicolon (;)


 3. Comments

Single-line comment

Multi-line comment


 Variables in C#


 Data Types (Basic)

Data Type Example
int int x = 10;
double double y = 5.5;
char char grade = 'A';
string string city = "Surat";
bool bool status = true;

 Output in C#


 Input in C#


 if Statement


 


 if–else Statement


 


 Loops

for Loop

while Loop


 Methods (Functions)


 Class Syntax


 Important Syntax Rules

  • Code blocks use curly braces { }

  • Main method is the entry point

  • Indentation improves readability

  • Strongly typed language


 Summary

✔ C# is case-sensitive
✔ Statements end with ;
✔ Uses {} for blocks
✔ Easy and readable syntax

You may also like...