CByte Function in VB.NET
How to Convert Integer to Byte Array in VB.NET?
Explanation
CByte Function - Convert Integer to Byte
CByte Function in Visual Basic.net 2008 is used to convert an integer in a Byte datatype. This function uses the system
locale settings to convert an expression to Byte.
Syntax:
CByte(expression)
Example:
Module Module1
Sub Main()
Dim x As Decimal = 12.123
Console.WriteLine("Value of Decimal expression converted
to Byte datatype is:: " & CByte(x))
Console.ReadLine()
End Sub
End Module
Result:
Value of Decimal expression converted to Byte datatype is:: 12
In the above example, two strings are compared in an expression the CByte() is used to convert an integer to
byte datatype.