c#,运算符,if else 语句

运算符
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
//数学运算符加减乘除模
int a = 1;
int b = 2;
int c = a + b;
c = a++;//a++相当于a=a+1,++a=a先计算a前面的后加
Console.WriteLine(c);
Console.WriteLine(a);
//比较运算符:> < >= <= <> == !=
// bool bo=a==b;
// Console.WriteLine(bo);
//逻辑运算符 && || !,!用在小括号前面的
bool bo;
bo = a > b && a > 2;
Console.WriteLine();
//赋值运算符+=、-=、*=、/=、&=、||=、%=、
a = a + b;//等同于a+=b

//条件运算符(比较表达式)?(语句一):(语句二);
//满足条件运行语句一,不满足条件运行语句二
c=(a > b)?(a +1):(b+1);
Console.WriteLine(c);
string s;
s = Console.ReadLine();
a = a+int.parse(s.tostring());
Console.WriteLine(s);
Console.ReadLine();
}
}
}
/*语句:
* 分支语句 :if,if else ,if elseif else, switch case
* 循环语句:for,while,do while,foreach
* 跳转语句:break,continue
* 异常语句:try, catch ,finally
**/
int a = 0;
if (a > 0)
{
Console.WriteLine("这是一个正数");
if (a > 10)
{
Console.WriteLine("这是一个大于十的数");
}

}
else
{
Console.WriteLine("这是一个小于0的数");
}
Console.ReadLine();

转载于:https://www.cnblogs.com/liuyuwen900326/p/4157515.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值