Replacement() private method

Returns the replacement result for a single match
private Replacement ( Match match ) : string
match Match
return string
        /// <summary>
        /// Returns the expansion of the passed replacement pattern. For
        /// example, if the replacement pattern is ?$1$2?, Result returns the concatenation
        /// of Group(1).ToString() and Group(2).ToString().
        /// </summary>
        public virtual string Result(string replacement)
        {
            if (replacement == null)
            {
                throw new ArgumentNullException(nameof(replacement));
            }

            if (_regex == null)
            {
                throw new NotSupportedException(SR.NoResultOnFailed);
            }

            // Gets the weakly cached replacement helper or creates one if there isn't one already.
            RegexReplacement repl = RegexReplacement.GetOrCreate(_regex._replref, replacement, _regex.caps, _regex.capsize,
                                                                 _regex.capnames, _regex.roptions);

            return(repl.Replacement(this));
        }
        public virtual string Result(string replacement)
        {
            if (replacement == null)
            {
                throw new ArgumentNullException("replacement");
            }
            if (this._regex == null)
            {
                throw new NotSupportedException(SR.GetString("NoResultOnFailed"));
            }
            RegexReplacement replacement2 = (RegexReplacement)this._regex.replref.Get();

            if ((replacement2 == null) || !replacement2.Pattern.Equals(replacement))
            {
                replacement2 = RegexParser.ParseReplacement(replacement, this._regex.caps, this._regex.capsize, this._regex.capnames, this._regex.roptions);
                this._regex.replref.Cache(replacement2);
            }
            return(replacement2.Replacement(this));
        }