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();
            }
        }
    }
  • 相关阅读:
    realsense d435i qt 测试
    realsense d435i 数据 测试
    realsense d435i测试
    ubuntu torch GPU yolov5
    IfcLayeredItem
    ubuntu大服务器 pytorch环境配置
    condarc内容
    realsense point cloud
    yolov5 环境配置
    pip error
  • 原文地址:https://www.cnblogs.com/fish7/p/4181165.html
Copyright © 2011-2022 走看看