c++数据类型大小受操作平台的影响,而在c#中,数据类型的定义都以与平台无关的方式定义,以备将来C#和.NET迁移到其他平台上。

这里说一下浮点类型在c#语言中的定义。

c#可以支持float ,double和decimal浮点数据类型。

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace ConsoleApplication1
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             Console.WriteLine("sizeof float={0},double={1},decimal={2}",sizeof(float),sizeof(double),sizeof(decimal));
14             Console.ReadKey();
15         }
16     }
17 }

运行结果:

sizeof float=4,double=8,decimal=16

 

相关文章:

  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-01
猜你喜欢
  • 2021-08-11
  • 2021-05-02
  • 2021-04-25
  • 2021-05-24
  • 2021-09-17
  • 2021-07-30
  • 2022-12-23
相关资源
相似解决方案