BooleanConverter Class

Definition

Provides a type converter to convert Boolean objects to and from various other representations.

public class BooleanConverter : System.ComponentModel.TypeConverter
Inheritance
BooleanConverter

Inherited Members

System.ComponentModel.TypeConverter

System.Object

Examples

The following code example converts a variable of type Boolean to and from a string.

bool bVal(true);
String^ strA = "false";
Console::WriteLine( TypeDescriptor::GetConverter( bVal )->ConvertTo( bVal, String::typeid ) );
Console::WriteLine( TypeDescriptor::GetConverter( bVal )->ConvertFrom( strA ) );
bool bVal=true;
string strA="false";
Console.WriteLine(TypeDescriptor.GetConverter(bVal).ConvertTo(bVal, typeof(string))); 
Console.WriteLine(TypeDescriptor.GetConverter(bVal).ConvertFrom(strA));
Dim bVal As Boolean = True
Dim strA As String = "false"
Console.WriteLine(TypeDescriptor.GetConverter(bVal).ConvertTo(bVal, GetType(String)))
Console.WriteLine(TypeDescriptor.GetConverter(bVal).ConvertFrom(strA))

Remarks

This converter can only convert a Boolean object 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 BooleanConverter. Instead, call the GetConverter method of the TypeDescriptor class. For more information, see the examples in the TypeConverter base class.

Constructors

BooleanConverter()

Initializes a new instance of the BooleanConverter class.

Methods

CanConvertFrom(ITypeDescriptorContext, Type)

Gets a value indicating whether this converter can convert an object in the given source type to a Boolean object using the specified context.

ConvertFrom(ITypeDescriptorContext, CultureInfo, Object)

Converts the given value object to a Boolean object.

GetStandardValues(ITypeDescriptorContext)

Gets a collection of standard values for the Boolean data type.

GetStandardValuesExclusive(ITypeDescriptorContext)

Gets a value indicating whether the list of standard values returned from the GetStandardValues(ITypeDescriptorContext) method is an exclusive list.

GetStandardValuesSupported(ITypeDescriptorContext)

Gets a value indicating whether this object supports a standard set of values that can be picked from a list.