ConvertTo() public méthode

Returns an Int32 (or null) from an AttributeColumn.
Conversion to the is not supported.
public ConvertTo ( object sourceValue, Type destinationType, IFormatProvider formatProvider, bool ignoreCase ) : object
sourceValue object The to convert.
destinationType System.Type The type to convert to.
formatProvider IFormatProvider An to use during conversion.
ignoreCase bool Whether to ignore case during conversion.
Résultat object
        public void ConvertAttributeColumnToString()
        {
            var converter = new AttributeColumnTypeConverter();
            var column    = new AttributeColumn(null, 42);

            Assert.IsFalse(converter.CanConvertTo(column, typeof(string)));
            converter.ConvertTo(column, typeof(string), CultureInfo.InvariantCulture, false);
        }
        public void ConvertAttributeColumnToNullableInteger()
        {
            var converter = new AttributeColumnTypeConverter();
            var column    = new AttributeColumn(null, null);

            Assert.IsTrue(converter.CanConvertTo(column, typeof(int?)));
            int?value = (int?)converter.ConvertTo(column, typeof(int?), CultureInfo.InvariantCulture, false);

            Assert.IsNull(value);
        }
        public void ConvertAttributeColumnToInteger()
        {
            var converter = new AttributeColumnTypeConverter();
            var column    = new AttributeColumn(null, 42);

            Assert.IsTrue(converter.CanConvertTo(column, typeof(int)));
            int value = (int)converter.ConvertTo(column, typeof(int), CultureInfo.InvariantCulture, false);

            Assert.AreEqual <int>(42, value);
        }