{
    
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代码:

 

{
    
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
    


		
C# 类型 byte,int,short,long,decimal,double,float


相关文章:

  • 2021-04-26
  • 2021-10-05
  • 2021-12-09
  • 2021-11-30
  • 2021-09-15
  • 2021-05-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2021-09-22
  • 2021-10-24
  • 2021-05-19
相关资源
相似解决方案