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();
        }

    }

}
posted @ 2007-12-05 13:55  东明  阅读(290)  评论(0)    收藏  举报