using System.Collections.Generic;
using System.Text.RegularExpressions;
public static class StringExtensions
public static T SafeParse<T>(this string str)
if (!string.IsNullOrEmpty(str))
result = (T) Convert.ChangeType(str, typeof(T));
decimal n = s.SafeParse<decimal>();