c#中分支语句的运用:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{
//int x = 5;
//int y = 3;
& | ^ ~
&两个都是一才为1
//int z = x & y;
x=0101
y=0011
&-----------
z=0001(2)
//Console.WriteLine(z);
【c#中分支语句的运用:】|两个有一个为一就为1
//z = x | y;
x=0101
y=0011
z=0111(7)
//Console.WriteLine(z);
^两个不同就为1
//z = x ^ y;
x=0101
y=0011
z=0110(6)
//Console.WriteLine(z);
~一元运算符相反值
//z = ~x;
x=0101
z=1010(-6)
//Console.WriteLine(z);

//z = x >> 2;
x=0101
z=0001(1)
//Console.WriteLine(z);
//z = x << 2;
x=00000101
z=00010100
//Console.WriteLine(z);
//int x = 5;
//Console.WriteLine(x==5?"x=5":"x!=5");
//int x = 5;
//int y = 6;
//string str;
//str = x == y ? "等于" : "不等于";
//Console.WriteLine(str);
//int y = 5;
//if (y == 5)
//{
//Console.WriteLine("y=5");
//}
int x = 0;
lba:
Console.WriteLine("你喜欢吃什么?A:苹果; B:香蕉; C:梨子");
switch (Console.ReadLine().ToUpper())
{
case "A":
Console.WriteLine("你喜欢吃苹果!");
break;
case "B":
Console.WriteLine("你喜欢吃香蕉!");
break;
case "C":
Console.WriteLine("你喜欢吃梨子!");
break;
default:
Console.WriteLine("你真够馋的!");
break;
}
Console.WriteLine();
Console.WriteLine("还选吗?A:断续B:不选");
if (Console.ReadLine().ToUpper()=="A")
{
if (x>2)
{
Console.WriteLine("还吃呀撑死你!");
return;
}
x++;
goto lba;
}
}
}
}
转载于:https://www.cnblogs.com/xfwfy/archive/2008/12/29/1364208.html

    推荐阅读