简体   繁体   English

C#是否具有int8和uint8?

[英]Does C# have int8 and uint8?

I have four questions: 我有四个问题:

  1. Does C# have int8 C#是否具有int8
  2. If so, how can I convert a string to int8 ? 如果是这样,如何将string转换为int8
  3. Does C# have uint8 C#是否具有uint8
  4. If that how can I convert a string to uint8 ? 如果那样我如何将string转换为uint8
  1. Does C# have int8 C#是否具有int8

Yes, it's called sbyte 是的,它叫做sbyte

  1. If so, how can I convert a string to int8 ? 如果是这样,如何将string转换为int8

Call sbyte.Parse or sbyte.TryParse 调用sbyte.Parsesbyte.TryParse

  1. Does C# have uint8 C#是否具有uint8

Yes, it's called byte 是的,这叫做byte

  1. If that how can I convert a string to uint8 ? 如果那样我如何将string转换为uint8

Call byte.Parse or byte.TryParse 调用byte.Parsebyte.TryParse

I believe you can use sbyte for signed 8-bit integers, as follows: 我相信您可以将sbyte用于带符号的8位整数,如下所示:

sbyte sByte1 = 127;

You can also use byte for unsigned 8-bit integers, as follows: 您还可以将byte用于无符号的8位整数,如下所示:

byte myByte = 255;

Here are some links for sbyte and byte : 这是sbytebyte一些链接:

General Integral type tables 通用整体类型表
sbyte documentation sbyte文档
byte documentation 字节文档

  1. Yes, the c# equivalent is known as sbyte 是的,C#等效项称为sbyte
  2. Convert.ToSByte( string ) Convert.ToSByte(string)
  3. Yes, the c# equivalent is known as byte 是的,C#等效项称为字节
  4. Convert.ToByte( string ) Convert.ToByte(string)

For more info on the equivalent data types, check out a link 有关等效数据类型的更多信息,请查看链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM