代码改变世界

布尔运算符和位运算符

2012-04-24 16:50  精诚所至 金石为开  阅读(312)  评论(0编辑  收藏  举报

本示例创建演示布尔运算符和位运算符的使用。

using System;
namespace a
{
	class Program
	{
		public static void Main(string[] args)
		{
			Console.WriteLine("Enter an integer:");
			int myInt =Convert.ToInt32(Console.ReadLine());
			Console.WriteLine("Integer less than 10? {0}",myInt<10);
			Console.WriteLine("Integer between 0 and 5? {0}",(0<=myInt) && (myInt<=5));
			Console.WriteLine("Bitwise AND of Integer and 10={0}", myInt & 10);
			Console.ReadKey();
		}
	}
}