zoukankan      html  css  js  c++  java
  • C#笔记1__命名空间 / 常量 / object / is、as、...?... :...

    命名空间:namespace Test1{ ... }    

    引用命名空间:using System;

    using 别名=命名空间

    常量:const double PI=3.14;

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Test1{
        class Program{
            static void Main(string[] args){
                object ob;
                ob = 10;
                Console.WriteLine(ob.GetType());
                ob = true;
                Console.WriteLine(ob.GetType());
                ob = 10.13m;
                Console.WriteLine(ob.GetType());
    
                Console.ReadLine();
            }
        }
    }
    namespace Test1{
        class Program{
            static void Main(string[] args){
                int a = 10;
                if (a is bool) //表达式 is 类型 
                    Console.WriteLine("yes");
                else
                    Console.WriteLine("no");
    
                object[] nums = new object[3];
                nums[0] = 123;
                nums[1] = "hell";
                nums[2] = "字符串";
                for (int i = 0; i < nums.Length; ++i) {
                    //表达式 as 引用类型       当as指定的转换不能实现时,运算结果为null
                    string s = nums[i] as string; //将数组nums的对应元素转换成字符串
                    Console.WriteLine("nums[{0}]", i);
                    if (s != null) {
                        Console.WriteLine("not a null");
                    } else {
                        Console.WriteLine("is a null");
                    }
                }
                bool k1 = 5 > 3 ? true : false;
                Console.WriteLine(k1);
                
    
                Console.ReadLine();
            }
        }
    }
  • 相关阅读:
    html的入门——从标签开始(2)
    Idea快捷键
    Java_core复习
    gitblit重置管理员密码【gitblit】
    使用命令创建git仓库
    Windows平台下搭建自己的Git服务器【gitblit】
    python笔记
    代码整洁之道
    Vue学习02
    Vue学习01
  • 原文地址:https://www.cnblogs.com/fish7/p/4181165.html
Copyright © 2011-2022 走看看