|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在数组前面加一个空字符串
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str"></param>
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 转换string为int?
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="intValue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|