C# 类型 byte,int,short,long,decimal,double,float
2009-10-07 00:48
471 查看
C# 类型 byte,int,short,long,decimal,double,float
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSType
{
public class myInt
{
public myInt()
{
//byte类型从0 -> 255。
byte xb = 1; //整型1隐式转换成byte类型.如果整数大于255,则产生异常(错误)
Console.WriteLine(xb.GetType());
// output System.Byte
//doesn't work
//byte xb1 = 256;
int xi = 1;
Console.WriteLine(xi.GetType());
//output System.Int32
short xs = 2;
Console.WriteLine(xs.GetType());
//output System.Int16
long xl = 3;
Console.WriteLine(xl.GetType());
//output System.Int64
//doesn't work , ushort,uint,ulong表示无符号的short,int,long,普通点说,就是没有负数,只有正数和0
//ushort xus = -1;
ushort xus = 1;
Console.WriteLine(xus.GetType());
//output System.UInt16
uint xui = 2;
Console.WriteLine(xui.GetType());
//output System.UInt32
ulong xul = 3;
Console.WriteLine(xul.GetType());
//output System.UInt64
decimal xd = 2; //整型2隐式转换成decimal类型
Console.WriteLine(xd.GetType());
//output System.Decimal
Console.WriteLine(xd);
float xf = 2f;
Console.WriteLine(xf.GetType());
//output System.Single -- 单精度
double xdo = 2; // 整型2隐式转换成double类型
Console.WriteLine(xdo.GetType());
//output System.Double -- 双精度
Console.WriteLine(xdo);
Console.ReadLine();
}
}
}
program.cs代码:
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSType
{
class Program
{
static void Main(string[] args)
{
//new myBool();
//new MyType();
new myInt();
}
}
}
下载完整程序包
0
0
(请您对文章做出评价)
posted @ 2009-01-06 14:59 无尽思绪 阅读(900) 评论(0) 编辑 收藏 网摘 所属分类: .Net(c#,asp.net)
相关文章推荐
- C# 类型 byte,int,short,long,decimal,double,float
- java Byte和各数据类型(short,int,long,float,double)之间的转换
- Java基础-数据类型int,short,char,long,float,double,boolean,byte
- java中byte、short、int、long、float、double类型的取值范围
- java Byte和各数据类型(short,int,long,float,double)之间的转换
- null可以转换成任意非基本类型(int/short/long/float/boolean/byte/double/char以外)
- java 基本数值类型:byte short int long float double char
- java byte、short、int、long、float、double、char基本数据类型范围
- 关于8个基本的数据类型:byte,short,int,long,float,double,char,boonlean
- 【C#】数据类型(sbyte,byte,short,ushort,int,uint,long,ulong和char。、、、)
- java 彻底理解 byte char short int float long double (转)
- (JAVA & C)数据类型取值范围——short int long float double等
- java int short long float double 类型描述以及原子性说明
- java 彻底理解 byte char short int float long double
- 【转】java 彻底理解 byte char short int float long double
- C#中int、long、float、double、decimal最大值最小值
- 有关C++的数据类型(int,long,short,float,double等等)
- C++ bool,char,short,int,long,float,double数据类型大小以及数据溢出值求解
- java 彻底理解 byte char short int float long double
- c语言基本数据类型short、int、long、char、float、double