Short answer (requires c#8):
string? NormalizeLength(string value, int maxLength) { return value?.PadRight(maxLength)[..maxLength].Trim(); }