Languages
[Edit]
EN

C#/.NET - convert int to byte

2 points
Created by:
aaliyah
471

In C#/.NET type can be converted to byte in few ways.

1. Convert.ToByte example

Edit

Output:

Note: Convert.ToByte prevents value overflowing (min value 0, max value 255).

2. Explicit conversion

Edit

Output:

Note: This kind of conversion cuts most significant bits!

3. References

Edit
  1. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/casting-and-type-conversions
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

C# conversion

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join