instead of a string, try to declare an enumeration as follows
public enum Month { January = 1, February, March, .... so on }
then pass it to the function and use the following functions in your function.
return System.DateTime.DaysInMonth(year, month);
Instead of a string, try using an integer, as this will reduce the overhead of syntax strings.
source share