Files

23 lines
625 B
C#

namespace Utils
{
public static class StringExtensions
{
public static string ReplaceLast(this string str, string oldValue, string newValue)
{
int index = str.LastIndexOf(oldValue);
return index < 0
? str
: str.Remove(index, oldValue.Length)
.Insert(index, newValue);
}
public static string CapitalizeFirstLetter(this string input)
{
if (string.IsNullOrEmpty(input))
return input;
return char.ToUpper(input[0]) + input.Substring(1);
}
}
}