首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

如#00,1,1#00,2,2#00,3,3#怎么转换成数组

2012-01-05 
如#00,1,1#00,2,2#00,3,3#如何转换成数组?换成数组:00 1 100 2 200 3 3[解决办法]C# codestring str #0

如#00,1,1#00,2,2#00,3,3#如何转换成数组?
换成数组:
00 1 1
00 2 2
00 3 3

[解决办法]

C# code
string str = "#00,1,1#00,2,2#00,3,3#";string[] ar = str.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);string[][] ar1=new string[ar.Length][];for (int i = 0; i < ar.Length; i++){    if (!string.IsNullOrEmpty(ar[i]))    {        ar1[i] = ar[i].Split(',');    }}
[解决办法]
如果#00,1,1#00,2,2#00,3,3#是字符串,那么先用replace将逗号替换为空格,然后用split按#号分组

[解决办法]
活用string.splite,经常会碰到的
[解决办法]
恩,splite

热点排行