System.ComponentModel.TypeTypeConverter.ConvertTo C# (CSharp) Method

ConvertTo() public method

public ConvertTo ( ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType ) : object
context ITypeDescriptorContext
culture System.Globalization.CultureInfo
value object
destinationType System.Type
return object
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string)) {
                return ((Type)value).FullName;
            }
            return base.ConvertTo(value, destinationType);
        }

Usage Example

Example #1
0
		public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
		{
			TypeTypeConverter converter = new TypeTypeConverter();

			value = converter.ConvertFrom(context, CultureInfo.CurrentCulture, value);
			value = base.EditValue(context, provider, value);
			value = converter.ConvertTo  (context, CultureInfo.CurrentCulture, value, typeof(string));

			return value;
		}