zoukankan      html  css  js  c++  java
  • C# 语法练习(1): 基本数据类型

    本例效果图:



    代码:
    using System;
    
    class MyClass
    {
        static void Main()
        {
            Console.WriteLine("sbyte 类型:");
            sbyte sbyteVar = (sbyte.MaxValue + sbyte.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", sbyte.MinValue, sbyteVar, sbyte.MaxValue);
    
            Console.WriteLine("byte 类型:");
            byte byteVar = (byte.MaxValue + byte.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", byte.MinValue, byteVar, byte.MaxValue);
    
            Console.WriteLine("short 类型:");
            short shortVar = (short.MaxValue + short.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", short.MinValue, shortVar, short.MaxValue);
    
            Console.WriteLine("ushort 类型:");
            ushort ushortVar = (ushort.MaxValue + ushort.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", ushort.MinValue, ushortVar, ushort.MaxValue);
    
            Console.WriteLine("int 类型:");
            int intVar = (int.MaxValue + int.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", int.MinValue, intVar, int.MaxValue);
    
            Console.WriteLine("uint 类型:");
            uint uintVar = (uint.MaxValue + uint.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", uint.MinValue, uintVar, uint.MaxValue);
    
            Console.WriteLine("long 类型:");
            long longVar = (long.MaxValue + long.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", long.MinValue, longVar, long.MaxValue);
    
            Console.WriteLine("ulong 类型:");
            ulong ulongVar = (ulong.MaxValue + ulong.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", ulong.MinValue, ulongVar, ulong.MaxValue);
    
            Console.WriteLine("float 类型:");
            float floatVar = (float.MaxValue + float.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", float.MinValue, floatVar, float.MaxValue);
    
            Console.WriteLine("double 类型:");
            double doubleVar = (double.MaxValue + double.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", double.MinValue, doubleVar, double.MaxValue);
    
            Console.WriteLine("decimal 类型:");
            decimal decimalVar = (decimal.MaxValue + decimal.MinValue) / 2;
            Console.WriteLine("{0}、{1}、{2}\n", decimal.MinValue, decimalVar, decimal.MaxValue);
    
            Console.WriteLine("char 类型:");
            char charVar = '万';
            Console.WriteLine("{0}、{1}\n", charVar, ++charVar);
    
            Console.WriteLine("bool 类型:");
            bool boolVar = true;
            Console.WriteLine("{0}、{1}\n", boolVar, !boolVar);
    
            Console.WriteLine("string 类型:");
            string stringVar = "万一的 Delphi 博客";
            Console.WriteLine("{0}、Length: {1}\n", stringVar, stringVar.Length);
    
            Console.ReadKey();
        }
    }
    
  • 相关阅读:
    go_base_03_if_for_switch_goto_流程控制
    go_base_02_dataType_常用数据类型
    go_base_01_var_const_变量和常量
    go_install_01_golang开发环境安装配置
    go_install_02_golang插件安装
    数据封装和私有属性
    类变量 实例变量 属性查找顺序
    微服务架构之「 服务注册 」
    Nginx配置https证书
    Go:go程序报错Cannot run program "C:UsersdellAppDataLocalTemp\___go_build_hello_go.exe" (in directory "…………"):该版本的 %1 与你运行的 Windows 版本不兼容。
  • 原文地址:https://www.cnblogs.com/del/p/1364557.html
Copyright © 2011-2022 走看看