////// 保证数据长度相同 /// /// /// /// 后填充/前填充 ///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 = 0; i < count; i++) { name += " "; } return name; } else { string value = ""; for (int i = 0; i < count; i++) { value += " "; } value += name; return value; } }