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.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -