NLog.Targets.FileTarget.ReplaceNumberPattern C# (CSharp) Method

ReplaceNumberPattern() private static method

Replaces the numeric pattern i.e. {#} in a file name with the value parameter value.
private static ReplaceNumberPattern ( string pattern, int value ) : string
pattern string File name which contains the numeric pattern.
value int Value which will replace the numeric pattern.
return string
        private static string ReplaceNumberPattern(string pattern, int value)
        {
            int firstPart = pattern.IndexOf("{#", StringComparison.Ordinal);
            int lastPart = pattern.IndexOf("#}", StringComparison.Ordinal) + 2;
            int numDigits = lastPart - firstPart - 2;

            return pattern.Substring(0, firstPart) + Convert.ToString(value, 10).PadLeft(numDigits, '0') +
                   pattern.Substring(lastPart);
        }