Dart StringBuffer writeCharCode()
Syntax & Examples
StringBuffer.writeCharCode() method
The `writeCharCode` method in Dart adds the string representation of the specified character code to the buffer.
Syntax of StringBuffer.writeCharCode()
The syntax of StringBuffer.writeCharCode() method is:
void writeCharCode(int charCode)
This writeCharCode() method of StringBuffer adds the string representation of charCode
to the buffer.
Parameters
Parameter | Optional/Required | Description |
---|---|---|
|
Return Type
StringBuffer.writeCharCode() returns value of type void
.
✐ Examples
1 Writing character code 65 to the buffer
In this example,
- We create a `StringBuffer` named `buffer`.
- We use the `writeCharCode()` method to add the character represented by the code 65 ('A') to the buffer.
- We convert the buffer to a string using `toString()` and print it to standard output.
Dart Program
void main() {
StringBuffer buffer = StringBuffer();
buffer.writeCharCode(65);
print(buffer.toString());
}
Output
A
2 Writing character code 97 to the buffer
In this example,
- We create a `StringBuffer` named `buffer`.
- We use the `writeCharCode()` method to add the character represented by the code 97 ('a') to the buffer.
- We convert the buffer to a string using `toString()` and print it to standard output.
Dart Program
void main() {
StringBuffer buffer = StringBuffer();
buffer.writeCharCode(97);
print(buffer.toString());
}
Output
a
3 Writing character code 33 to the buffer
In this example,
- We create a `StringBuffer` named `buffer`.
- We use the `writeCharCode()` method to add the character represented by the code 33 ('!') to the buffer.
- We convert the buffer to a string using `toString()` and print it to standard output.
Dart Program
void main() {
StringBuffer buffer = StringBuffer();
buffer.writeCharCode(33);
print(buffer.toString());
}
Output
!
Summary
In this Dart tutorial, we learned about writeCharCode() method of StringBuffer: the syntax and few working examples with output and detailed explanation for each example.