C#_is运算符,new运算符,typeof运算符

来源:互联网 发布:淘宝商品降价提醒 编辑:程序博客网 时间:2024/06/14 16:50
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace CShapeTest{    class Start    {        static void Main(string[] args)        {            // is 运算符,判断是否是该类型,如果是,返回真, 如果不是,返回假            int i = 10;            bool result = i is int;            Console.WriteLine("{0}", result);            // new 运算符,创建一个引用对象            string[] ls = new string[3];            ls[0] = "asp.net";            ls[1] = "C#";            ls[2] = "Java";            Console.WriteLine("{0}", ls[0]);            Console.WriteLine("{0}", ls[1]);            Console.WriteLine("{0}", ls[2]);            // type 运算符,可以获取系统类型的对象            Type _type = typeof(string);            Console.WriteLine("{0}", _type);            Console.ReadLine();        }    }}

0 0
原创粉丝点击