I have a function that very often are called. Any tip on how to optimize this code:
Code:private static double CalculateDifferance(object from, object to) { if (typeof(int) == from.GetType()) { return (int)to - (int)from; } else if (typeof(DateTime) == from.GetType()) { return ((DateTime)to - (DateTime)from).TotalSeconds; } else if(typeof(double) == from.GetType()) { return (double)to - (double)from; } return double.NaN; }




Reply With Quote