《零基础学C#》第六章-实例06:字符串拆分——练习1

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wtxhai/article/details/88662069
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Example606_01
{
    class Program
    {
        static void Main(string[] args)
        {
            //声明字符串
            Console.Write("请输入要拆分的字符串:");
            string str = Console.ReadLine();
            char[] separator = { '。' };//声明分割字符的数组
            //分割字符串
            string[] splitStrings = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            //使用for循环遍历数组,并输出
            for (int i = 0; i < splitStrings.Length; i++)
            {
                Console.WriteLine(splitStrings[i]);
            }
            Console.ReadLine();
        }
    }
}

猜你喜欢

转载自blog.csdn.net/wtxhai/article/details/88662069
今日推荐