C#入门4.7——其他运算符

1.字符串连接运算符+

将两个字符串连在一起组成一个新的字符串

str1="my name is"  str2="jojo";

string str3=str1+str2;

2.is运算符

用于动态检查对象的运行时类型是否与给定类型兼容。

bool=a is string

判断is左边的变量是否与is右边的类型相同。

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=10;
            double b=10.0;
            string c="hello";
            bool mybool=false;
            mybool = a is int;
            Console.WriteLine("a is int.\t" + mybool);
            mybool = b is double;
            Console.WriteLine("b is double.\t" + mybool);
            mybool = c is string;
            Console.WriteLine("c is string.\t" + mybool);
            Console.ReadKey();
        }
    }
}

\t的意思是跳到下一个制表位

3.三元运算符

表达式1?表达式2:表达式3;

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)
        {

            Console.WriteLine("请输入你拥有钢笔的数量");
            int qty = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("I have {0} pen{1}.",qty,qty>1?"s":"");
            Console.ReadKey();
        }
    }
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
net framework4.7.2安装包,这款net framework4.72工具包是最新离线版,nbsp;.NET Framework 4.7.2是针对Microsoft .NET Framework 4、4.5、4.5.1、4.5.2、4.6、4.6.1和4.6.2的就地更新,兼容性良好,支持独立安装。本款net framework4.7.2官方版是玩家们游戏的必备插件,帮助玩家们顺利体验游戏。.NET Framework 4.7.2的更新内容: 支持Windows10上的Windows Forms应用高分辨率设置支持Windows10上的WPF应用触摸增强加密支持支持C# 7和VB 15,包括ValueTuple支持.NET标准v1.6性能和可靠性提升使用方法1.下载解压缩2.直接安装net framework4.7工具包3.重启电脑生效适应系统:.NET Framework 4支持的操作系统:Windows Server 2003; Windows Server 2008; Windows Server 2008R2; Windows Vista; Windows XP; Windows 7.NET Framework 4.5支持的操作系统:Windows 7;Windows 8 ;Windows Server 2008;Windows Server 2008 R2;Windows Server 2012.NET Framework 4.6支持的操作系统:Windows 7 Service Pack 1, Windows 8, Windows 8.1, Windows Server 2008 R2 SP1, Windows Server 2008 Service Pack 2, Windows Server 2012, Windows Server 2012 R2, Windows Vista Service Pack 2注意:Windows 8和 Windows Server 2012 已包括 .NET Framework 4.5。因此,您不必在这些操作系统上安装此软件。Microsoft .NET Framework 4.7适用于Windows 7 SP1、Windows 8.1、Windows 10一周年更新、Windows Server 2008 R2 SP1、Windows Server 2012、Windows Server 2012 R2和Windows Server 2016。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值