File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
content/dart/concepts/type-conversion/terms/toString Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ Title : ' .toString()'
3
+ Description : ' Converts the object into a string representation.'
4
+ Subjects :
5
+ - ' Code Foundations'
6
+ - ' Computer Science'
7
+ - ' Mobile Development'
8
+ Tags :
9
+ - ' Dart'
10
+ - ' Data Types'
11
+ - ' Method'
12
+ - ' Strings'
13
+ CatalogContent :
14
+ - ' learn-dart'
15
+ - ' paths/computer-science'
16
+ ---
17
+
18
+ In Dart, the ** ` .toString() ` ** method converts the object into a string representation.
19
+
20
+ ## Syntax
21
+
22
+ ``` pseudo
23
+ typeObject.toString()
24
+ ```
25
+
26
+ Above, ` typeObject.toString() ` calls the ` toString() ` method on the object ` typeObject ` .
27
+
28
+ ## Example
29
+
30
+ The following example demonstrates how the ` .toString() ` method is used to convert numbers to a string:
31
+
32
+ ``` dart
33
+ void main() {
34
+ int numbers = 123;
35
+ var result = numbers.toString();
36
+ print(result);
37
+ }
38
+ ```
39
+
40
+ The code shown above will generate the following output:
41
+
42
+ ``` shell
43
+ 123
44
+ ```
45
+
46
+ > ** Note:** The output ` 123 ` is a string. This can be confirmed by checking ` result is String ` and ` result.runtimeType ` .
You can’t perform that action at this time.
0 commit comments