the shortcut operators
class MainClass
{
public static void Main()
{
int length = 1;
length += 10;
System.Console.WriteLine("length = " + length);
length *= 2; // multiplies length by 2
System.Console.WriteLine("length = " + length);
length /= 3; // divides length by 3
System.Console.WriteLine("length = " + length);
}
}
Output length = 11
length = 22
length = 7
|
HTML code for linking to this page:
|