samnang
12/26/2010 - 12:30 PM

csharp_example.cs

//Swap value between two variables
int a = 5, b = 10;
int temp = a;
a = b;
b = temp;

//Output message 3 times
for(int i = 0; i <= 3; i++)
    Console.WriteLine("Hello");

//Output message if condition is true string
str = string.Empty;
if(str == string.Empty)
    Console.WriteLine("str is empty");
#Swap value between two variables
a, b = 5, 10
a, b = b, a

#Output message 3 times
3.times { puts "Hello" }

#Output message if condition is true
str = ''
puts "str is empty" if str.empty?