01.using System;
02.class Test6
03.{
04. public static void Main()
05. {
06. string str = "";
07. while (str.Length <= 3)
08. {
09. Console.Write("请输入一个长度大于3的字符串:");
10. str = Console.ReadLine();
11. }
12. //(1)
13. Console.WriteLine("字符串的长度为:{0}", str.Length);
14. //(2)
15. int i = str.IndexOf('a');
16. if (i > -1)
17. {
18. Console.WriteLine("第一个出现字母a的位置是:{0}", i);
19. }
20. else
21. {
22. Console.WriteLine("字符串中不包含字母a。");
23. }
24. //(3)
25. string str1 = str.Insert(3, "hello"); //在第3个(初始序号为)字符前插入hello
26. Console.WriteLine("插入hello后的结果为:{0}", str1);
27. //(4)
28. string str2 = str1.Replace("hello", "me");
29. Console.WriteLine("将hello替换为me后的结果为:{0}", str2);
30. //(5)
31. string[] arr = str2.Split('m');
32. Console.WriteLine("以m为分隔符分离后的字符串有:");
33. for (int j = 0; j < arr.Length; j++)
34. {
35. Console.WriteLine(arr[j]);
36. }
37. }
38.}