G
Guest
Hi all
If I have a method for inserting data to database and it take a parameter dateTime in String. Since C# does not have a function to test date like IsDate in VB.Net. Would it be a good idea to use a static method in a static object to convert the dateTime to DateTime datatype as follows
public static DateTime ParseDate(String dateTime
tr
return DateTime.Parse(dateTime)
catc
return null; // Not sure about what to return, error occurs
}
Does the use of the static method cause the performance of the application decrease? if so, for the case above, should I just put the content of the static method at the original method(the point of use)
Would it be always a good practice not to make any assumption and test the validity of the parameter of the method
Thanks for your hel
Simon
If I have a method for inserting data to database and it take a parameter dateTime in String. Since C# does not have a function to test date like IsDate in VB.Net. Would it be a good idea to use a static method in a static object to convert the dateTime to DateTime datatype as follows
public static DateTime ParseDate(String dateTime
tr
return DateTime.Parse(dateTime)
catc
return null; // Not sure about what to return, error occurs
}
Does the use of the static method cause the performance of the application decrease? if so, for the case above, should I just put the content of the static method at the original method(the point of use)
Would it be always a good practice not to make any assumption and test the validity of the parameter of the method
Thanks for your hel
Simon