Tải bản đầy đủ (.pdf) (1 trang)

Tài liệu Chapter 5 Quick Reference pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.51 KB, 1 trang )



Chapter 5 Quick Reference
To Do this
Add an amount to a variable
Use the compound addition operator. For
example:
variable += amount;
Subtract an amount from a variable
Use the compound subtraction operator. For
example:
variable -= amount;
Run one or more statements while a
condition is true
Use a while statement. For example:
int i = 0;
while (i != 10)
{
Console.WriteLine(i);
i++;
}
Alternatively, use a for statement. For
example:
for (int i = 0; i != 10; i++)
{
Console.WriteLine(i);
}
Repeatedly execute statements one or
more times
Use a do statement. For example:
int i = 0;


do
{
Console.WriteLine(i);
i++;
}
while (i != 10);



×