c#字符串操作2

来源:互联网 发布:unity3d模型格式 编辑:程序博客网 时间:2024/06/07 10:06
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{   class Program    {        static void Main(string[] args)        {            string str = "This is an Apple.";            int num1=str.Split('A').Length-1;            Console.WriteLine("This is an Apple.");            Console.Write("A在其中共出现");            Console.Write(num1);            Console.WriteLine("次!");            int num2 = str.Split(' ').Length;            Console.Write("在其中共出现");            Console.Write(num2);            Console.WriteLine("个单词!");            string str1 = str.ToUpper();            Console.WriteLine(str1);            char[] str2 = str.ToCharArray();            char[] str3 = new char[str2.Length];            for (int i = 0; i < str2.Length ; i++)            {                str3[str2.Length - i-1] = str2[i];             }                Console.WriteLine(str3);            Console.ReadLine();        }    }}

0 0
原创粉丝点击