Construct | Ruby Construct | C# Construct |
---|---|---|
Comment | # | // /* ... */ /// |
Variable Declaration |
int workerSalary; | |
Variable Assignment |
worker_salary = 19.55 | workerSalary = 19.55; |
Selection |
if hours > 40 overtime_hours = hours - 40 end |
if (hours > 40) { overtime_hours = hours - 40; } |
if n == 1 word = "one" elsif n == 2 word = "two" elsif n == 3 word = "three" else word = "many" end |
if (n == 1) { word = "one"; } elsif (n == 2) { word = "two"; } elsif (n == 3) { word = "three"; } else { word = "many"; } |
|
case statement |
switch(n) { case 1: word = "one"; break; case 2: word = "one"; break; default: word = "many"; } |
|
Repetition |
sum = 0 while n < 100 sum = 0 n += 1 end |
sum = 0; while (n < 100) { sum = 0; n++; } |
for n in [1..n] sum = 0 n += 1 end |
sum = 0; for(i = 1; i <= 100; i++) { sum = 0; n++; } |
|
Function Definition |
def fahrenheit(temp) return 9 * temp / 5 + 32 end |
int fahrenheit(int temp) { return 9 * temp / 5 + 32; } |