Code Review 2
This commit is contained in:
1 parent
9158a69b62
commit
368280fcb5
8 files changed
+54
-45
No files matched your search
@@ -189,7 +189,7 @@ public static class StringExtensions {
|
||||
/// 过短则用 <paramref name="code"/> 将其左侧填充,过长则截取靠左的指定长度。
|
||||
/// </summary>
|
||||
public static string EnsureLength(this string? str, char code, int length) {
|
||||
if (str == null) str = "";
|
||||
str ??= "";
|
||||
return str.Length > length ? str.Substring(0, length) : str.PadLeft(length, code);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user