System.ComponentModel.TypeConverter.ConvertFrom C# (CSharp) Method

ConvertFrom() public method

public ConvertFrom ( object value ) : object
value object
return object
        public object ConvertFrom(object value) {
            return ConvertFrom(null, CultureInfo.CurrentCulture, value);
        }

Same methods

TypeConverter::ConvertFrom ( ITypeDescriptorContext context, CultureInfo culture, object value ) : object

Usage Example

        /// <inheritdoc />
        public override bool TryConvert(object value, Type destinationType, out object result, ConversionArgs args)
        {
            System.ComponentModel.TypeConverter converter = TypeDescriptor.GetConverter(destinationType);
            if (converter.GetType() != typeof(System.ComponentModel.TypeConverter) && converter.CanConvertFrom(value.GetType()))
            {
                try {
                    result = converter.ConvertFrom(null, args.Culture, value);
                    return(true);
                }
                catch {
                }
            }

            converter = TypeDescriptor.GetConverter(value.GetType());
            if (converter.GetType() != typeof(System.ComponentModel.TypeConverter) && converter.CanConvertTo(destinationType))
            {
                try {
                    result = converter.ConvertTo(null, args.Culture, value, destinationType);
                    return(true);
                }
                catch {
                }
            }

            result = null;
            return(false);
        }
All Usage Examples Of System.ComponentModel.TypeConverter::ConvertFrom