volcanol的工控博客
Email : lilinly225@126.com 索要资料加QQ 点击进入 或 点击左侧的资料分享专用帖

volcanol ---- View OF Linux Can Appreciate Nature OF Linux

天行健,君子以自强不息

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  219 随笔 :: 0 文章 :: 587 评论 :: 46万 阅读
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


//namespace 关键字用来定义命名空间,命名空间主要用来解决命名冲突的问题
//命名空间还有一个作用是将一组相关的类组织到一个抽象空间里面,必须引用
//命名空间,才能访问命名空间的内容
namespace ConsoleApplication1  
{
    class Program
    {
        static void Main(string[] args)
        {
            //C#内置了很多简单数据类型,也可以称为基本数据类型
            //主要分为三大类: 整型数据、浮点型数据和字符类型

            //整型数据类型: short、int、long
            //同时需要注意,整型数据具有有符号和无符号两种,

            //byte 8bit
            Console.WriteLine("sbyte类型最大值为:" + sbyte.MaxValue);
            Console.WriteLine("sbyte类型最小值为:" + sbyte.MinValue);
            Console.WriteLine("byte类型最大值为:" + byte.MaxValue);
            Console.WriteLine("byte类型最小值为:" + byte.MinValue);

            //short  16bit
            Console.WriteLine("short类型最大值为:" + short.MaxValue);
            Console.WriteLine("short类型最小值为:" + short.MinValue);
            Console.WriteLine("ushort类型最大值为:" + ushort.MaxValue);
            Console.WriteLine("ushort类型最小值为:" + ushort.MinValue);

            //int  32bit
            Console.WriteLine("int类型的最大值为:" + int.MaxValue);
            Console.WriteLine("int类型的最小值为:" + int.MinValue);
            Console.WriteLine("uint类型的最大值为:" + uint.MaxValue);
            Console.WriteLine("uint类型的最小值为:" + uint.MinValue);

            //long  64bit
            Console.WriteLine("long类型的最大值为:" + long.MaxValue);
            Console.WriteLine("long类型的最小值为:" + long.MinValue);
            Console.WriteLine("ulong类型的最大值为:" + ulong.MaxValue);
            Console.WriteLine("ulong类型的最小值为:" + ulong.MinValue);


            //浮点数有三种类型: float、double、decimal
            //其中decimal数据类型用于货币计算,数据精度高,就是小数点后面的有效数字多
            
            //字符类型有两种:  char 和 string
            //char是一种unicode字符类型,可以表示宽字符集

            //在C#中一般不能进行隐式类型转换,需要进行显示数据类型转换
            Console.WriteLine("char类型的最大值为:" + (long)char.MaxValue );
            Console.WriteLine("char类型的最小值为:" + (long)char.MinValue);
            Console.WriteLine("char类型的最大值表示的字符为:" + (char)char.MaxValue);
            Console.WriteLine("char类型的最小值表示的字符为:" + (char)char.MinValue);

            //string是一种unicode类型的字符串
            string strGreeting;
            Console.WriteLine("请输入欢迎语:");
            strGreeting = Console.ReadLine();
            Console.WriteLine("您输入的欢迎语为:" + strGreeting);

            //注意,C#中进行字符串的连接可以用两个方式,用重载过的运算符 + 或者 join函数
            //因为还没有学习到模板的内容,这里暂时不介绍了

            //最后还有一个特殊的基本数据类型bool类型,它有两个值 true 和 false
            //需要注意的是,C#与C, C#与C++不同的是,非零值不能隐式的表示bool量
            if (true)
                Console.WriteLine("使用了true常量");

            /*
             * 下面的强制类型转换不能成功,所以这个地方需要特别的注意
            if((bool)1)
                Console.WriteLine("使用了true常量");

           */

            Console.Read();
        }
    }
}
复制代码

 

 

--------------------------------------------------------------分割线---------------------------------------------------------------

1、文章均为个人原创,欢迎转载,转载请保留出处:https://www.cnblogs.com/volcanol/

2、获取工控PLC、变频器、HMI、计算机、Windows、Linux、嵌入式资料点击:获取资料

3、如果您觉得文章对您有帮助可转至页面上半部分打赏,或移步:打赏 

4、或者在页面右下角点推荐哟!!!

--------------------------------------------------------------分割线---------------------------------------------------------------

 

posted on   volcanol  阅读(1810)  评论(0编辑  收藏  举报
编辑推荐:
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
阅读排行:
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
volcanol ----View OF Linux Can Appreciate Nature OF Linux。
点击右上角即可分享
微信分享提示