为什么要在C#中的字节被命名为字节为sbyte不像其他整数类型? [英] Why bytes in c# are named byte and sbyte unlike other integral types?

查看:610
本文介绍了为什么要在C#中的字节被命名为字节为sbyte不像其他整数类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是通过规范翻转,发现字节为奇数。其他人则短,USHORT,INT,UINT,long和ulong。为什么这个命名为sbyte和字节而不是字节和UBYTE的?

I was just flipping through the specification and found that byte is odd. Others are short, ushort, int, uint, long, and ulong. Why this naming of sbyte and byte instead of byte and ubyte?

推荐答案

这是一个语义学问题。当你想到一个字节你通常(至少我)觉得从0-255的8位值。所以,这就是字节是。二进制数据的不常见的解释是-128到127有符号值(为sbyte )。

It's a matter of semantics. When you think of a byte you usually (at least I do) think of an 8-bit value from 0-255. So that's what byte is. The less common interpretation of the binary data is a signed value (sbyte) of -128 to 127.

通过整数,它更直观地认为,在签署的价值观方面,所以这就是基本的名字风格代表。在 U 前缀则允许访问不常见的无符号的语义。

With integers, it's more intuitive to think in terms of signed values, so that's what the basic name style represents. The u prefix then allows access to the less common unsigned semantics.

这篇关于为什么要在C#中的字节被命名为字节为sbyte不像其他整数类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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