Version 8.x.x TrimOrNullify - PawelGerr/Thinktecture.Runtime.Extensions GitHub Wiki

TrimOrNullify

Convenience method for trimming, truncating and nullifying of string.

  • If string is empty or containing whitespace only, then the method returns null.
  • Otherwise the string is trimmed
  • If parameter maxLength is provided then the string will be shortened if necessary.
string value = ...;

var trimmedOrNull = value.TrimOrNullify();

var trimmedAndShortenedOrNull = value.TrimOrNullify(maxLength: 10);
⚠️ **GitHub.com Fallback** ⚠️