C#下的单一结构 [英] Single Structure under C#

查看:63
本文介绍了C#下的单一结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道多少字节包含类型为System.Single 的值0x80000L888?

I want to know how many byte contains the value 0x80000L888 which is of type System.Single ?

推荐答案

Single始终为4个字节,无论您存储在其中的号码.

但是,您不能为其分配0x80000L888-"L"不是有效的十六进制数字!
A Single is always 4 bytes, regardless of the number you store in it.

However, you can''t assign 0x80000L888 to it - ''L'' is not a valid hex digit!


要了解您可能在下面使用的值类型的大小,

To know size of a value type you could probably use below,

static void Main(string[] args)
{
    Console.WriteLine("{0}",sizeof(Single));
}



:)



:)


您称单个结构为?其实是结构吗?是的,没有.所有原始类型都以其原始形式或盒装形式出现.只有盒装形式是结构.这两种形式的大小不同(盒装较大;而且,它是一类).

阅读有关拳击的信息: http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx [^ ].

—SA
You call single a structure? It is a structure in fact? Yes and no. All primitive types comes in their original form or in a boxed form. Only a boxed form is a structure. These two forms have different size (boxed is larger; also, it''s a class).

Read about boxing: http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx[^].

—SA


这篇关于C#下的单一结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆