内容创作者一定要学会在飞书多维表上用Sora大模型!功能太强大了
2026/1/16 20:00:44
在C#中,字符串是Unicode字符数组。例如,string s = "Hi there.";声明并初始化了一个字符串变量s。调用s.ToUpper()方法会返回一个全大写的字符串副本,但原字符串s不会改变。示例代码如下:
string s = "Hi there."; Console.WriteLine("{0}", s.ToUpper()); // Print uppercase copy Console.WriteLine("{0}", s); // String is unchanged此代码的输出为:
HI THERE. Hi there.另外,StringBuilder类可用于创建可修改的字符串。它是System.Text命名空间下的BCL成员,其实例是可变的Unicode字符数组。示例代码如下:
using System.Text; StringBuilder sb = new StringBuilder("Hi there."); Console.WriteLine("{