您的位置:首页 > 编程语言 > C#

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)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: