66 lines
1.6 KiB
C#
66 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace JY.Inspection.Common
|
|
{
|
|
public class StrUtil
|
|
{
|
|
/// <summary>
|
|
/// 前端字节补0
|
|
/// </summary>
|
|
/// <param name="str"></param>
|
|
/// <param name="count"></param>
|
|
/// <returns></returns>
|
|
public static string GetStartString(string str, int count)
|
|
{
|
|
string strRes = str;
|
|
int strCount = str.Length;
|
|
|
|
if (strCount != count)
|
|
{
|
|
strRes = str.PadLeft(count, '0');
|
|
|
|
}
|
|
return strRes;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加结尾字节长度
|
|
/// </summary>
|
|
/// <param name="str"></param>
|
|
/// <param name="count"></param>
|
|
/// <returns></returns>
|
|
public static string GetEndString(string str, int count)
|
|
{
|
|
string strRes = str;
|
|
int strCount = str.Length;
|
|
|
|
if (strCount != count)
|
|
{
|
|
|
|
strRes = str.PadRight(count, ' ');
|
|
|
|
}
|
|
return strRes;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成字符串List集合
|
|
/// </summary>
|
|
/// <param name="Num"></param>
|
|
/// <returns></returns>
|
|
public static List<string> GetListString(int Num, string str)
|
|
{
|
|
List<string> list = new List<string>();
|
|
for (int i = 0; i < Num; i++)
|
|
{
|
|
list.Add(str);
|
|
}
|
|
return list;
|
|
}
|
|
}
|
|
}
|