基本数据类型
每种数据类型都有相应的范围,超出范围的值被赋值的话会报错
float赋值必须要加f!!!
using System; namespace Lesson05 { class MainClass { public static void Main (string[] args) { Console.WriteLine ("Hello World!"); int num = 5; float h = 1.67f; string name = "老王"; /* 整型类型 */ sbyte a = 4; Console.WriteLine (a); byte b = 5; // 短整型 short c = 4; ushort d = 5; // 整型 uint e = 4; // 长整型 long g = 6; ulong hh= 7; /* 小数类型 */ // 单精度浮点数 float z= 4.056f; double x= 4.056; // 字符串类型 string str= "老王"; // 布尔类型 bool u = true; u = false; //类型 + 变量名 //int 类型变量会在内存中占用4个字节空间(32位)一个字节8位 Console.WriteLine ("short占用"+sizeof(short)); } } }
链接:http://edu.csdn.net/course/detail/1982/30921?auto_start=1
转载请注明原文地址: https://ju.6miu.com/read-1124649.html