Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ByteConverter Class

Provides a type converter to convert 8-bit unsigned integer objects to and from various other representations.

For a list of all members of this type, see ByteConverter Members.

System.Object
   System.ComponentModel.TypeConverter
      System.ComponentModel.BaseNumberConverter
         System.ComponentModel.ByteConverter

[Visual Basic]
Public Class ByteConverter
   Inherits BaseNumberConverter
[C#]
public class ByteConverter : BaseNumberConverter
[C++]
public __gc class ByteConverter : public BaseNumberConverter
[JScript]
public class ByteConverter extends BaseNumberConverter

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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 Implementing 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.

Example

[Visual Basic, C#, C++] The following 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.

[Visual Basic] 
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))

[C#] 
byte myUint = 5;
string myUStr = "2";
Console.WriteLine(TypeDescriptor.GetConverter(myUint).ConvertTo(myUint, typeof(string))); 
Console.WriteLine(TypeDescriptor.GetConverter(myUint).ConvertFrom(myUStr));    

[C++] 
Byte myUint( 5 );
String* myUStr = S"2";
Console::WriteLine(TypeDescriptor::GetConverter(__box(myUint))->ConvertTo(__box(myUint), __typeof(String)));
Console::WriteLine(TypeDescriptor::GetConverter(__box(myUint))->ConvertFrom(myUStr));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.ComponentModel

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

ByteConverter Members | System.ComponentModel Namespace

Show:
© 2017 Microsoft