using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HighWayIot.Winform.Business { public class GeneralUtils { /// /// 在数组前面加一个空字符串 /// /// public static string[] HeadAddEmptyString(string[] str) { Array.Resize(ref str, str.Length + 1); Array.Copy(str, 0, str, 1, str.Length - 1); str[0] = string.Empty; return str; } /// /// 转换string为int? /// /// /// public static int? StringNullOrToInt(string intValue) { if (string.IsNullOrEmpty(intValue.Trim())) { return null; } if (int.TryParse(intValue, out int result)) { return result; } else { return null; } } public static string IntEmptyOrToString(int? value) { if (value == null) { return string.Empty; } else { return value.ToString(); } } } }