ByteConverter
Class
Definition
Provides a type converter to convert 8-bit unsigned integer objects to and from various other representations.
public class ByteConverter : System.ComponentModel.BaseNumberConverter
- Inheritance
Inherited Members
System.ComponentModel.BaseNumberConverter
System.ComponentModel.TypeConverter
System.Object
Examples
The following code example declares and initializes an 8-bit unsigned integer and a string. The code then converts each of them to the other's type, respectively.
Byte myUint(5);
String^ myUStr = "2";
Console::WriteLine( TypeDescriptor::GetConverter( myUint )->ConvertTo( myUint, String::typeid ) );
Console::WriteLine( TypeDescriptor::GetConverter( myUint )->ConvertFrom( myUStr ) );
byte myUint = 5;
string myUStr = "2";
Console.WriteLine(TypeDescriptor.GetConverter(myUint).ConvertTo(myUint, typeof(string)));
Console.WriteLine(TypeDescriptor.GetConverter(myUint).ConvertFrom(myUStr));
Dim myUint As Byte = 5
Dim myUStr As String = "2"
Console.WriteLine(TypeDescriptor.GetConverter(myUint).ConvertTo(myUint, GetType(String)))
Console.WriteLine(TypeDescriptor.GetConverter(myUint).ConvertFrom(myUStr))
Remarks
This converter can only convert an 8-bit unsigned integer to and from a string.
For more information about type converters, see the TypeConverter base class and How to: Implement a Type Converter.
Note
You should never create an instance of a ByteConverter. Instead, call the GetConverter method of TypeDescriptor. For more information, see the examples in the TypeConverter base class.
Constructors
| ByteConverter() |
Initializes a new instance of the ByteConverter class. |