Ejemplo n.º 1
0
        public BString Replace(BString Old, BString New, int StartAt)
        {
            if (StartAt >= this.Length)
            {
                throw new Exception("Starting postition cannot be greater than Length");
            }

            if (Old.Length > this.Length)
            {
                return(new BString(this._elements));
            }

            BStringBuilder builder = new BStringBuilder();

            bool found = false;

            for (int i = StartAt; i < this.Length; i++)
            {
                found = (i >= this.Length - Old.Length ? false : BString.Equals(this, i, Old, 0, Old.Length));
                if (!found)
                {
                    builder.Append(this[i]);
                }
                else
                {
                    builder.Append(New);
                    i += Old.Length - 1;
                }
            }

            return(builder.ToBString());
        }
Ejemplo n.º 2
0
        // Concatenations //
        public static BString Concat(BString A, BString B)
        {
            BStringBuilder builder = new BStringBuilder();

            builder.Append(A);
            builder.Append(B);
            return(builder.ToBString());
        }
Ejemplo n.º 3
0
        public static BString Concat(IEnumerable <BString> Elements)
        {
            BStringBuilder builder = new BStringBuilder();

            foreach (BString u in Elements)
            {
                builder.Append(u);
            }
            return(builder.ToBString());
        }