Organizational Research By

Surprising Reserch Topic

Difference between byte vs Byte data types in C# ?


I noticed that in C# there are both a byte and Byte data type. They both say they are of type struct System.Byte and represent an 8-digit unsigned integer.

So I am curious as to what the difference if any is between the two, and why you would use one over the other.


asked May 9, 2015 in Asp.Net by rajesh
0 votes
20 views



Related Hot Questions

1 Answer

0 votes

The byte keyword is an alias for the System.Byte data type.

They represent the same data type, so the resulting code is identical. There are only some differences in usage:

  • You can use¬†byte¬†even if the¬†System¬†namespace is not included. To use¬†Byte¬†you have to have a¬†using System;¬†at the top of the page, or specify the full namespace¬†System.Byte.

  • There are a few situations where C# only allows you to use the keyword, not the framework type, for example:

.

enum Fruits : byte // this works
{
  Apple, Orange
}

enum Fruits : Byte // this doesn't work
{
  Apple, Orange
}
answered May 9, 2015 by rajesh

...