Converts a char to a byte .
[Edit]
Parameters
- value
- The Unicode character to be converted interpreted as an unsigned value.
[Edit]
Returns
value as a byte.
[Edit]
Exceptions
Remarks
Example
The following example demonstrates converting char values
to byte values.
C# Example |
using System;
class ConvertByteTest {
static public void Main() {
char char0 = '0';
char char1 = '1';
char char2 = 'a';
byte byte0 = Convert.ToByte(char0);
byte byte1 = Convert.ToByte(char1);
byte byte2 = Convert.ToByte(char2);
Console.WriteLine("(char) {0} as byte = {1}",char0,byte0);
Console.WriteLine("(char) {0} as byte = {1}",char1,byte1);
Console.WriteLine("(char) {0} as byte = {1}",char2,byte2);
}
}
|
The output is
(char) 0 as byte = 48
(char) 1 as byte = 49
(char) a as byte = 97
Requirements
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0