学习笔记(11):C#急速入门-变量类型-数字类型

立即学习:https://edu.csdn.net/course/play/20589/257719?utm_source=blogtoedu

_______________________________________________________________________________________________________

人生碌碌,竞短论长,却不道荣枯有数,得失难忘。

_______________________________________________________________________________________________________

整数类型

sbyte :在-128 ~127之间的整数

byte :在0~255之间的整数

short :在-32768~32767之间的整数

ushort:在0~65535之间的整数

int : 在-2147483648 ~ 2147483647之间的整数

uint:在0 ~ 4294967295 之间的整数

long:在-9223372036854775808~ 9223372036854775807之间的整数

ulong:在0~18446744073709551615之间的整数

            byte myByte = 100;
            int myInt = 23;
            long myLong = 10000003002;

            Console.WriteLine("MyByte={0},MyInt={1},MyLong={2}", myByte, myInt, myLong);
            Console.ReadKey();

小数类型

//如果存储的数字位数超出范围,会报错
            double d = 3.14;//默认小数为double类型
            float f = 3.14f;//经度低,数字后加f表示float类型
            decimal dc = 0.155255m;//精度高,适合表示金钱的变量,数字后加m表示decimal类型
发布了16 篇原创文章 · 获赞 7 · 访问量 160

猜你喜欢

转载自blog.csdn.net/weixin_44944420/article/details/105285775