You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB
C#

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>
/// 转换
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static int? StringNullOrToInt(string text)
{
return int.TryParse(text, out int result) ? (int?)result : null;
}
public static string IntEmptyOrToString(int? value)
{
if (value == null)
{
return string.Empty;
}
else
{
return value.ToString();
}
}
}
}