I'm trying to create an extension method for string
that says whether the string is a valid integer, double, bool or decimal. I'm not interested in switch..case and trying to use generics.
Extension method
public static bool Is<T>(this string s)
{
....
}
Usage
string s = "23";
if(s.Is<int>())
{
Console.WriteLine("valid integer");
}
I couldn't able to succeed on implementing the extension method. I'm looking for some ideas/suggestions...