日期:2014-06-10  浏览次数:20564 次

字符串的长度:

使用字符串的length;

 1  class Program
 2     {
 3         static void Main(string[] args)
 4         {
 5             Console.WriteLine("请输入一句话:");
 6            string str= Console.ReadLine();
 7            int count= StrLength(str);
 8             Console.WriteLine(count);
 9             Console.ReadKey();
10 
11         }
12         /// <summary>
13         /// 获取用户输入的字符串长度
14         /// </summary>
15         /// <param name="str"></param>
16         /// <returns></returns>
17         private static int StrLength(string str)
18         {
19             return str.Length;
20         }
21     }
View Code