Download CustomTypeConverter1.zip version 1.0.0.0, last updated 28/07/2013 (12.74 KB)

Download
  • md5: b750911ae2f67565a562ace5615f3f06
using System.ComponentModel;
using System.Globalization;

/*
  Custom Type Converter Sample 1
  http://cyotek.com/blog/creating-a-custom-typeconverter-part-1
*/

namespace CustomTypeConverter1
{
  [TypeConverter(typeof(LengthConverter))]
  internal class Length
  {
    #region Overridden Members

    public override string ToString()
    {
      string value;
      string unit;

      value = this.Value.ToString(CultureInfo.InvariantCulture);
      unit = this.Unit.ToString();

      return string.Concat(value, unit);
    }

    #endregion

    #region Properties

    public Unit Unit { get; set; }

    public float Value { get; set; }

    #endregion
  }
}

Donate

Donate