YuriyGuts.RegexBuilder.ExtensionMethods.ReplaceMany C# (CSharp) Method

ReplaceMany() public static method

public static ReplaceMany ( this builder, string oldValues, string newValues ) : void
builder this
oldValues string
newValues string
return void
        public static void ReplaceMany(this StringBuilder builder, string[] oldValues, string[] newValues)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }

            if (oldValues == null || newValues == null)
            {
                throw new ArgumentNullException
                (
                    oldValues == null ? "oldValues" : "newValues",
                    "Search and replacement arrays should both be not-null."
                );
            }

            if (oldValues.Length != newValues.Length)
            {
                throw new ArgumentException("Search and replacement arrays should have equal lengths.");
            }

            for (int i = 0; i < oldValues.Length; i++)
            {
                builder.Replace(oldValues[i], newValues[i]);
            }
        }
ExtensionMethods