在C#中,可以使用字符串的Length屬性來統計字符串的長度。示例如下:
string str = "Hello, World!"; int length = str.Length; Console.WriteLine("字符串的長度為:" + length);
上面的代碼將打印出字符串”Hello, World!”的長度為13。