/// <summary>
/// 保证数据长度相同
/// </summary>
/// <param name="obj"></param>
/// <param name="len"></param>
/// <param name="afterFill">后填充/前填充</param>
/// <returns></returns>
public string GetSameLenString(object obj, int len, bool afterFill = true)
{
string name = obj.ToString();
//int count = len - name.Length;//不能用这个 汉字和英文占用的长度不同
int count = len - System.Text.Encoding.Default.GetBytes(name).Length;
if (afterFill)
{
for (int i = ; i < count; i++)
{
name += " ";
}
return name;
}
else
{
string value = "";
for (int i = ; i < count; i++)
{
value += " ";
}
value += name;
return value;
}
}