19 lines
490 B
C#
19 lines
490 B
C#
namespace BotSharp.Abstraction.Utilities;
|
|
|
|
public static class StringExtensions
|
|
{
|
|
public static string IfNullOrEmptyAs(this string str, string defaultValue)
|
|
=> string.IsNullOrEmpty(str) ? defaultValue : str;
|
|
|
|
public static string SubstringMax(this string str, int maxLength)
|
|
{
|
|
if (string.IsNullOrEmpty(str))
|
|
return str;
|
|
|
|
if (str.Length > maxLength)
|
|
return str.Substring(0, maxLength);
|
|
else
|
|
return str;
|
|
}
|
|
}
|