本文介绍了您好,对于以下方法,在c#中是否有ReDim Preserve的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public RolesProperties[] getDAta(RolesProperties OP)
        {
            string sqlstring = "";
            sqlstring = "select Id,user_role,details";
            sqlstring += "where 1=1";

            if (OP.ID != "") { sqlstring += "and Id=" + SqlFunctions.qt(OP.ID); }
            if (OP.USER_ROLE != "") { sqlstring += "and user_role" + SqlFunctions.qt(OP.USER_ROLE); }
            if (OP.ROLE_DETAILS != "") { sqlstring += "and details" + SqlFunctions.qt(OP.ROLE_DETAILS); }

            RolesProperties[] omain;
            SqlDataReader drx;
            dbDataReader dr = new dbDataReader();
            dr.ConnectionName = "ConnectionString";
            dr.SqlString = sqlstring;
            drx = dr.GetData();
            int cnt = 0;
            if (drx != null)
            {
                if (drx.HasRows)
                {
                    while (drx.Read())
                    {
                        RolesProperties oTmp = new RolesProperties();
                        oTmp.ID = (string)SqlFunctions.Nz(drx["Id"], "");
                        oTmp.USER_ROLE = (string)SqlFunctions.Nz(drx["user_role"], "");
                        oTmp.ROLE_DETAILS = (string)SqlFunctions.Nz(drx["details"], "");

                        //Array.Resize(ref omain, cnt + 1);
                        //omain[cnt] = oTmp;
                        //cnt += 1;

                        //if (omain != null)
                        //    Array.Copy(omain, temp, Math.Min(omain.Length, temp.Length));
                        //omain = temp;


                    }
                }
                drx.Close();
                drx = null;
                dr = null;
            }
            return omain;
        }



[edit]已添加代码块 - OriginalGriff [/ edit]


[edit]Code block added - OriginalGriff[/edit]

推荐答案


这篇关于您好,对于以下方法,在c#中是否有ReDim Preserve的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 02:51