Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

Name

StringBuilder

Synopsis

This String helper class enables in-place modification of a string without having to create new string instances. Since strings are immutable, their values cannot change once set. (Attempts to assign a new value to an existing string succeed, but at the expense of destroying and re-creating the original string.) The StringBuilder constructor allows you to set the size of the StringBuilder and specify the initial string it contains. The Insert( ) methods put new data (of varying types) into the StringBuilder at a specified position. Append( ) adds data to the end of a StringBuilder. The ToString( ) method converts the StringBuilder into a real string.

public sealed class StringBuilder {
// Public Constructors
   public StringBuilder( );
   public StringBuilder(int capacity);
   public StringBuilder(int capacity, int maxCapacity);
   public StringBuilder(string value);
   public StringBuilder(string value, int capacity);
   public StringBuilder(string value, int startIndex, int length, int capacity);
// Public Instance Properties
   public int Capacity{set; get; }
   public int Length{set; get; }
   public int MaxCapacity{get; }
   public char this[int index]{set; get; }
// Public Instance Methods
   public StringBuilder Append(bool value);
   public StringBuilder Append(byte value);
   public StringBuilder Append(char value);
   public StringBuilder Append(char[ ] value);
   public StringBuilder Append(char[ ] value, int startIndex, int charCount);
   public StringBuilder Append(char value, int repeatCount ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# in a Nutshell

C# in a Nutshell

Ben Albahari, Ted Neward, Peter Drayton
C# 7.0 in a Nutshell

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Joe Mayo

Publisher Resources

ISBN: 0596005261Catalog PageErrata