Type conversion example in C# .NET using the IConvertible interface
December 2, 2015 1 Comment
In this we saw how to convert between numeric types explicitly and implicitly. There are other ways to implement conversions in C#. You must have come across the System.Convert static methods such as System.ConvertToInt32 or System.ConvertToByte.
You can implement your own conversions by implementing the IConvertible interface. Consider the following object:
public class House
{
public double Area { get; set; }
public int NumberOfRooms { get; set; }
public string Address { get; set; }
public bool ForSale { get; set; }
public DateTime DateBuilt { get; set; }
}