| Hello World |
cout << "Hello World"; |
Console.WriteLine("Hello World"); |
| Main Function |
int main() { ... } |
static void Main() { ... } |
| Variables |
int x = 5; |
int x = 5; |
| Strings |
string s = "text"; (needs <string>) |
string s = "text"; |
| Input |
cin >> x; |
x = Console.ReadLine(); |
| Output |
cout << x; |
Console.WriteLine(x); |
| Comments |
// single line<br>/* multi-line */ |
// single line<br>/* multi-line */ |
| Conditionals |
if (x > 0) {} |
if (x > 0) {} |
| Loops |
for (int i = 0; i < n; i++) {} |
for (int i = 0; i < n; i++) {} |
| Functions |
int add(int a, int b) { return a + b; } |
int Add(int a, int b) { return a + b; } |
| Classes |
class MyClass { ... }; |
class MyClass { ... } |
| Inheritance |
class Dog : public Animal {} |
class Dog : Animal {} |
| Arrays |
int arr[5]; |
int[] arr = new int[5]; |
| Lists/Vectors |
vector<int> v; (needs <vector>) |
List<int> list = new List<int>(); (needs System.Collections.Generic) |
| Namespaces |
namespace MySpace {} |
namespace MySpace {} |
| Exception Handling |
try { } catch (...) { } |
try { } catch (Exception e) { } |
| Memory Management |
Manual (new, delete) |
Automatic (Garbage Collection) |
| OOP Paradigm |
Optional |
Strongly enforced |
| Top-Level Statements |
❌ Not supported |
✅ Supported (C# 9+) |