c#分割字符串
最近做了一个项目,里面用到的了字符串的拆分,于是偶先把那个东东拿出来分享下。
using System;
using System.Collections.Generic;
using System.Text;
![]()
namespace Test_01
{
class Program
{
static void Main(string[] args)
{
// 声明字符串型变量str,用来存储格式字符
string str = "13700858848&ABCDEFGHIJKLMNOPQ";
![]()
// 分割字符,已“&”为分割点
string[] a = System.Text.RegularExpressions.Regex.Split(str, System.Text.RegularExpressions.Regex.Escape("&"));
![]()
Console.WriteLine(a.Length);
![]()
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine(a[i].ToString());
}
![]()
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Test_01
{
class Program
{
static void Main(string[] args)
{
// 声明字符串型变量str,用来存储格式字符
string str = "13700858848&ABCDEFGHIJKLMNOPQ";
// 分割字符,已“&”为分割点
string[] a = System.Text.RegularExpressions.Regex.Split(str, System.Text.RegularExpressions.Regex.Escape("&"));
Console.WriteLine(a.Length);
for (int i = 0; i < a.Length; i++)
{
Console.WriteLine(a[i].ToString());
}
Console.ReadLine();
}
}
}


浙公网安备 33010602011771号