public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
if (value is string) {
string text = (string)value;
if (text.Length > 1) {
text = text.Trim();
}
if (text != null && text.Length > 0) {
if (text.Length != 1) {
throw new FormatException(SR.GetString(SR.ConvertInvalidPrimitive, text, "Char"));
}
return text[0];
}
return '\0';
}
return base.ConvertFrom(context, culture, value);
}
}