Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BoolTest
- {
- static void Main()
- {
- //Gán b là true
- bool b = true;
- // In b ra. Nếu true in true, flase in false.
- Console.WriteLine(b);
- // lấy giá trị ngày hiện tại. ví dụ hm nay này 14/03/2013. Lấy ra 14
- int days = DateTime.Now.DayOfYear;
- // b sẽ bằng true/flase. Nếu <day> chia hết cho 2 thì là True ngược lại False. OK
- b = (days % 2 == 0);
- // Nếu b=true in ra. Ngược lại False in dòng dưới.
- // Viết (b==true) hay (b) cũng tương đương.
- if (b)
- {
- Console.WriteLine("days is an even number");
- }
- else
- {
- Console.WriteLine("days is an odd number");
- }
- }
- }
- /* Output:
- True
- days is an <even/odd> number
- */
Advertisement
Add Comment
Please, Sign In to add comment