本文介绍了是执行此ArrayList搜索的更好方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I并调用一个简单的过程以每行拉回12个值.似乎将其放入对象的数组列表中.这就是我正在做的....有没有更好/更快的方法?

I and calling a simple procedure to pull back 12 values per row. It seems to put it into an array list of objects. This is what I am doing....Is there a better/faster way?

        private void buildDynamicSort(string o)
        {
            ArrayList al = new ArrayList();
            if (ddr == null)
            {
                ddr = GenericCommand.ExecuteReader("GetTrkCustomField");
                while (ddr.Read())
                {
                    object[] values = new object[ddr.FieldCount];
                    ddr.GetValues(values);
                    al.Add(values);
                }
                foreach (var item in al)
                {
                    string[] arr = ((IEnumerable)item).Cast<object>()
                                  .Select(x => x.ToString())
                                  .ToArray();

                    switch (arr[12])
                    {
                        case "Numeric":
                            Console.WriteLine("Case 1");
                            break;
                        case "Text":
                            Console.WriteLine("Case 2");
                            break;
                        case "Dropdowns":
                            Console.WriteLine("Case 3");
                            break;
                        case "Date":
                            Console.WriteLine("Case 4");
                            break;
                    }
                }
            }
        }

www.helixpoint.com

www.helixpoint.com

推荐答案

    ddr = GenericCommand.ExecuteReader("GetTrkCustomField");
   while(ddr.Read())
   {
       switch(ddr.GetString(12))
       {
       大写字母"Numeric":
          Console.WriteLine(案例1");
            break;
           . . .
       }
   }

    ddr = GenericCommand.ExecuteReader( "GetTrkCustomField");
    while( ddr.Read())
    {
        switch( ddr.GetString(12))
        {
        case "Numeric":
            Console.WriteLine( "Case 1");
            break;
            . . .
        }
    }


这篇关于是执行此ArrayList搜索的更好方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 13:46