public static string ReplaceWithSpecialChar(this string value, int startLen, int endLen, char specialChar)
{
if (!value.IsNullOrEmpty() && value.Length > (startLen + endLen))
{
value = string.Create(value.Length, (value, startLen, endLen, specialChar), (dst, v) =>
{
ReadOnlySpan<char> startValue = v.value.Substring(0, v.startLen);
startValue.CopyTo(dst.Slice(0, startValue.Length));
int subLenth = v.value.Length - v.startLen - v.endLen;
subLenth = subLenth < 0 ? 0 : subLenth; ReadOnlySpan<char> specialValue = "".PadLeft(subLenth, v.specialChar); specialValue.CopyTo(dst.Slice(startValue.Length, subLenth)); ReadOnlySpan<char> endValue = subLenth >= 0 ? v.value.Substring(v.startLen + subLenth) : string.Empty;
endValue.CopyTo(dst.Slice(startValue.Length + subLenth, endValue.Length));
});
}
return value;
}