public static Int32 ToInt32(this Object line)
{
return Convert.ToInt32(line);
}
public class NumericExtensions
{
public static Int32 ToInt32(this Double line)
{
return (Int32)line;
}
public static Int32 ToInt32(this float line)
{
return (Int32)line;
}
public static Int32 ToInt32(this String line)
{
var res;
int.TryParse(line, out res);
return res;
}
// ... for each desired type
}
Find more questions by tags C#
After all, why limit the extension? To space not podskazala this method. Here and never will. I don't like too many unnecessary methods. - Rodger commented on July 12th 19 at 17:15