As C# doesn't have generic specialisation like C++ template specialisation and I wanted a way to be able to do it, I came up with a little hack that goes a bit like this:    public sealed class Specialisation<T>     {         private Specialisation() { }        private static Specialisation<T> instance = new Specialisation<T>();        public static Specialisation<T> Instance { get { return instance; } }    }    public interface ISpecialisable<T>    {        T SpecialisedMethod(Specialisation<T> t);    }    public class Specialised : ISpecialisable<int>, ISpecialisable<float>    {        public double Value;        public int SpecialisedMethod(Specialisation<int> t) { return (int)Value; }        public float SpecialisedMethod(Specialisation<float> t) { return (float)Value; }    }    public static class Program    {        public static void Main()        {           Specialised s = new Specialised();           s.Value = 12.3456789;           Console.WriteLine(s.SpecialisedMethod(Specialisation<int>.Instance));           Console.WriteLine(s.SpecialisedMethod(Specialisation<float>.Instance));           Console.ReadKey();        }    }Other than this not being the 'right way' to do things and being a complete mistreatment of the method overloading system, are there any possible side effects that could happen as a result of this horrible hack?EDIT:An applied example of specialisation in such a manner:    // assume Specialisation is unchanged    public interface IConvertible<T> // Not to be confused with System.IConvertible    {        T Convert(Specialisation<T> t);    }    public class ConvertMe : IConvertible<int>, IConvertible<float>    {        public double Value;        public int Convert(Specialisation<int> t) { return (int)Value; }        public float Convert(Specialisation<float> t) { return (float)Value; }    }    public static class Program    {        public static void Main()        {           ConvertMe c = new ConvertMe();           c.Value = 12.3456789;           Console.WriteLine(c.Convert(Specialisation<int>.Instance));           Console.WriteLine(c.Convert(Specialisation<float>.Instance));           Console.ReadKey();        }    }EDIT:Another example I just thought of as an extension of/alternative to the IConvertible<T> example. This technique allows the normal generic method syntax to be used externally, whilst allowing the class developer to internally define specialisations.public interface IConvertible<T>{    T Convert(Specialisation<T> t);    T Convert<T>();}// assume Specialisation<T> is unchangedpublic class ConvertMe : IConvertible<int>, IConvertible<float>{    public double Value;    int IConvertible<int>.Convert(Specialisation<int> t) { return (int)Value; }    float IConvertible<float>.Convert(Specialisation<float> t) { return (float)Value; }    public T Convert<T>() { return ((IConvertible<T>)this).Convert(Specialisation<T>.Instance); }}public static class Program{    public static void Main()    {        ConvertMe c = new ConvertMe();        c.Value = 12.3456789;        Console.WriteLine(c.Convert<int>());        Console.WriteLine(c.Convert<float>());        Console.ReadKey();    }}This use of specialisation could be generalised to other applications in order to provide specialised behaviour. I won't add any more examples as the ones provided are long enough as it is, and I'm sure everyone here has the skill and imagination to find other applications of this pattern.
Is this C# 'hack' a bad idea?
c#;c++;generics