数组转换

       //获取ListBox中的要删除的角色
        ArrayList deleteRoleArray = new ArrayList();
        foreach (ListItem item in lst_RestRole.Items)
        {
            string newRoleName = item.Text;
            //判断是否是已经存在的
            foreach (string oldRoleName in oldRoleNames)
            {
                //如果是已经存在的,那么就放入要删除的ArrayList中
                if (oldRoleName == newRoleName)
                {
                    deleteRoleArray.Add(newRoleName);
                    break;
                }
            }
        }

        //把ArrayList转换成String[]
        string[] addRoleNames = (string[])roleArray.ToArray(typeof(string));

posted @ 2009-06-10 06:58  Jason.Bird  阅读(346)  评论(0编辑  收藏  举报