c# - How to validate string can be convert to specific type? -
I have a string that can be int, date time, boolean, byte, etc. How do I validate that the string can be converted into those types without using TryParse of each type? public class generics manager {public static change chang type gt;)) {value = (T) Convert.changetap (data, Nullable.GetUnderlyingType (typeof t))); } And {if (data! = Null) {value = (t) convert.change type (data, typef (t)); } } return value; }} is not useful at large here, but I think you can use it, and can validate that the result is not equal to the default for that type . However, Tryparse is much better and you're trying to do.