乐闻世界logo
搜索文章和话题

How to Concatenate Two Strings in Dart?

2月7日 11:34

In Dart, you can use the plus sign (+) or string interpolation to concatenate two strings.

Method 1: Using the Plus Sign (+)

dart
String string1 = "Hello, "; String string2 = "World!"; String combined = string1 + string2; print(combined); // Output: Hello, World!

Method 2: Using String Interpolation

dart
String string1 = "Hello, "; String string2 = "World!"; String combined = "$string1$string2"; print(combined); // Output: Hello, World!
标签:Dart