Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does C# have int8 and uint8?

I have four questions:

  1. Does C# have int8
  2. If so, how can I convert a string to int8?
  3. Does C# have uint8
  4. If that how can I convert a string to uint8?
like image 699
Nayana Adassuriya Avatar asked Jul 25 '14 02:07

Nayana Adassuriya


2 Answers

  1. Does C# have int8

Yes, it's called sbyte

  1. If so, how can I convert a string to int8?

Call sbyte.Parse or sbyte.TryParse

  1. Does C# have uint8

Yes, it's called byte

  1. If that how can I convert a string to uint8?

Call byte.Parse or byte.TryParse

like image 169
Sergey Kalinichenko Avatar answered Oct 05 '22 22:10

Sergey Kalinichenko


I believe you can use sbyte for signed 8-bit integers, as follows:

sbyte sByte1 = 127; 

You can also use byte for unsigned 8-bit integers, as follows:

byte myByte = 255; 

Here are some links for sbyte and byte:

General Integral type tables
sbyte documentation
byte documentation

like image 29
Devarsh Desai Avatar answered Oct 05 '22 23:10

Devarsh Desai