
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
代码 2-16:逐字字符串(<stringDemo2>\Program.cs)
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace stringDemo2 { class Program { static void Main(string[] args) { //原创打油诗:) string poem=@" 小溪竹林边, 青山绿水依, 江河源于此, 卧虎藏龙地。"; Console.WriteLine(poem); } } }
代码的输出结果如图2-11所示。

图2-11
从中我们可以看出,在逐字字符串中,换行、空格等特殊字符都被原样输出了。
2.6.3 字符串的常用操作
1. 字符串的连接
在C#中,我们可以使用“+”运算符来连接两个字符串,如代码2-17所示。