² String.Split的用法 :在一个字符串中,根据本设有的定义的分割字符或字符串,进行字符串的分割,将分割开的字符串分别依次存入一个数组
成为数组内的不同元素。
² 了解使用Split(char),Split(char[])的区别: split[char] 和split(char[])的区别在于 设置的分割符的多少.
Split(char[])可以为分割字符串设置
多个分割符
但.split(char,char1)的用法也可以设置多个分割符,所以我还是不知道区别在哪,难道就是写法的不同?
除此之外还有 split(string[])
。。。根据字符串和字符串组来分割字符串 与上同理
关于split的案例
通常用于数据库的数据的存储
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Text;
using
System.Threading.Tasks;
namespace 字符串的分割
{
class Program
{
static void Main(string[] args)
{
string words = "坚持,可以创造奇迹!不幸的是很少有人,长时间的坚持下去,直至,奇迹发生。";
string[] split =
words.Split(new char[] { ',','!','!','.','。'});
foreach (string s in split)
{
Console.WriteLine(s +"\n");
}
Console.ReadLine();
}
}
}