
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Encoding Binary Data as Base64
|
55
The Remove method of the StringBuilder class is not overloaded and is straightfor-
ward to use. Simply give it a starting position and the number of characters to
remove. This method returns a reference to the same instance of the
StringBuilder
object with the Replace method that modified the string value.
The
Replace method of the StringBuilder class allows for fast character or string
replacement to be performed on the original
StringBuilder object. These methods
return a reference to the same instance of the
StringBuilder object with the Replace
method that was called. If you are performing a replace operation that uses a format
string under your control, then you should use the
AppendFormat method of the
StringBuilder class.
Note that this method is case-sensitive.
See Also
See the “String.Replace Method,” “String.Remove Method,” “StringBuilder.Replace
Method,” and “StringBuilder.Remove Method” topics in the MSDN documentation.
2.11 Encoding Binary Data as Base64
Problem
You have a byte[] representing some binary information, such as a bitmap. You
need to encode this data into a string so that it can be sent over a binary-unfriendly
transport such as email.
Solution
Using the static method Convert.ToBase64String on the Convert class, a byte[] may
be encoded ...