public static TStruct Add <TStruct>(this TStruct structValue, TStruct otherStructValue) where TStruct : struct, IComparable <TStruct> { if (typeof(TStruct) == typeof(int)) { int structValueInt = structValue.ConvertToType <int>(); int otherStructValueInt = otherStructValue.ConvertToType <int>(); int finalStructValueInt = structValueInt + otherStructValueInt; return(finalStructValueInt.ConvertToType <TStruct>()); } else if (typeof(TStruct) == typeof(uint)) { uint structValueUInt = structValue.ConvertToType <uint>(); uint otherStructValueUInt = otherStructValue.ConvertToType <uint>(); uint finalStructValueUInt = structValueUInt + otherStructValueUInt; return(finalStructValueUInt.ConvertToType <TStruct>()); } else if (typeof(TStruct) == typeof(long)) { long structValueLong = structValue.ConvertToType <long>(); long otherStructValueLong = otherStructValue.ConvertToType <long>(); long finalStructValueLong = structValueLong + otherStructValueLong; return(finalStructValueLong.ConvertToType <TStruct>()); } else if (typeof(TStruct) == typeof(ulong)) { ulong structValueULong = structValue.ConvertToType <ulong>(); ulong otherStructValueULong = otherStructValue.ConvertToType <ulong>(); ulong finalStructValueULong = structValueULong + otherStructValueULong; return(finalStructValueULong.ConvertToType <TStruct>()); } else { throw new NotSupportedException(string.Format("Type {0} is not supported currently!", typeof(TStruct))); } }