标签:
1 public static class StringHelper 2 { 3 public static int? ToIntNullable(this string obj) 4 { 5 if (obj == null || string.IsNullOrWhiteSpace(obj.ToString(CultureInfo.InvariantCulture))) 6 { 7 return null; 8 } 9 else 10 { 11 int offsetX = 0; 12 if (Int32.TryParse(obj.ToString(CultureInfo.InvariantCulture), out offsetX)) 13 { 14 return offsetX; 15 } 16 else 17 { 18 return null; 19 } 20 } 21 } 22 }
标签:
原文地址:http://www.cnblogs.com/JustYong/p/4441690.html