首页 新闻 会员 周边

asp.net 截取以四位数为单位的数据

0
悬赏园豆:15 [已解决问题] 解决于 2013-03-13 16:23
比如字段的数据是00930093009300930090
要怎么已四位的的整数显示出来
比如:93 93 93 93 90
DoLu的主页 DoLu | 初学一级 | 园豆:132
提问于:2013-03-12 14:39
< >
分享
最佳答案
0

public static void Main(string[] args)        

{            

   string str = "00930093009300930090";            

   List<string> lst = new List<string>();            

  Get(str, lst);            

  for (int i = 0; i < lst.Count; i++)            

  {                

    Console.WriteLine(int.Parse(lst[i]));            

  }        

}

 

public static void Get(string str,List<string> lst)        

{            

     string temp;               

    if (str.Length > 4)            

    {                

      temp = str.Substring(0, 4);                

      lst.Add(temp);                
      str = str.Remove(0, 4);                

      Get(str, lst);            

    }            

    else            

    {                

      lst.Add(str.Substring(0, str.Length));            

    }        

}

收获园豆:10
*^__^* | 菜鸟二级 |园豆:428 | 2013-03-12 16:53
其他回答(1)
0

你的问题不清楚

收获园豆:5
Yu | 园豆:12980 (专家六级) | 2013-03-12 16:12

现在可以了,只是不知道在DataList里面怎么绑定一个数组的方法

<%#Eval("AGroupValidCode")%>这里面怎么调用数组的一个方法

支持(0) 反对(0) DoLu | 园豆:132 (初学一级) | 2013-03-12 16:33

@DoLu: 在<%# 里面可以编写复杂代码,例如下面这样

            <asp:DataList runat="server" ID="dl">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lb" Text='<%# string.Join(",",(Eval("Value") as IEnumerable<int>).Select(x=>x.ToString())) %>'></asp:Label>
                </ItemTemplate>
            </asp:DataList>
支持(0) 反对(0) 陈希章 | 园豆:2538 (老鸟四级) | 2013-03-12 20:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册