class Program
{
static void Main()
{
//int a = 2, b = 3;
////二进制 10,11
//a = a ^ b; //a = 01 也就是1 b = 11
//b = a ^ b; //b = 10
//a = a ^ b;// a = 11
//Console.WriteLine(a);
//Console.ReadLine();
//int a = 5369;//实现两次乘以2
//编译器 将a转化成2进制 1010011111001
//乘以2 对于2进制 就是后面加 0
//结果 101001111100100 = a * 2
//string path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
//Console.WriteLine(path);
//string a = changeValue(2147483647, 2);
//Console.WriteLine(a);
//int i = 10;
//int b = i++ + i++ + i++;
//Console.WriteLine("b={0},i={1}",b,i);
//i = 1;
//i = i++;
//int b = i++;
//Console.WriteLine(i);
//Console.WriteLine(b);
//i = 1;
//int b = ++i;
//int c = i++;
//int count = 0;
//Test(0, ref count, 100);
//Console.WriteLine(count);
//Console.ReadLine();
////静态方法是属于类的
////非静态方法是属于对象的
////Program p = new Program();
////p.Test2(0, ref count, 100);
//Environment.Exit(0);
}
//private static void Test(int index, ref int count, int i)
//{
// if (index < i)
// {
// index++;
// count += index;
// Test(index, ref count, i);
// }
// else
// {
// return;
// }
//}
//private void Test2(int index, ref int count, int i)
//{
// if (index < i)
// {
// index++;
// count += index;
// Test(index, ref count, i);
// }
// else
// {
// return;
// }
//}
//private static string changeValue(int a, int b)
//{
// string ret = string.Format("a=[{0}],b = [{1}]", a, b) + Environment.NewLine;
// //a = a + b;
// //b = a - b;
// //a = a - b;
//编译器自动优化的特点
// a = b + (b = a) * 0;
// ret += string.Format("new a=[{0}], new b = [{1}]", a, b) + Environment.NewLine;
// return ret;
//}
}
交换两个变量的值
最新推荐文章于 2022-08-14 18:19:06 发布