Click here to Skip to main content
15,909,091 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
code in class
I make a datatable from an xml file, convert two strings into an array as milliseconds (int),
this goes Ok Also a text string comes out of the xml - this works.
(these are timein ,timeout and subtitle)
I need to store "stepper" and "stringArr" somewhere in memory to call it pretty fast without
accessing the XML over and over again to put subtitles in time in mediaelement.

Where to store the info for instant access?
C#
public void arrayprov(string blabla)
        {
            DataSet ds = new DataSet();
            ds.ReadXml(blabla);
            DataTable DT = new DataTable();
            // Take out property " number of subtitles " 
            DT = ds.Tables[0];
           // string subtstr = DT.Rows[0][8].ToString();
            int subtlen = Int32.Parse(DT.Rows[0][8].ToString())-1;
            double frate =double.Parse(DT.Rows[0][5].ToString());
            DT = ds.Tables[1];

            int[,] stepper = new int[subtlen, 2];
            string[] stringArr= new string[subtlen]
            
            for (int i = 0; i < subtlen; i++)
            {
                stepper[i, 0] = calcuul(DT.Rows[i][0].ToString(), frate); // intime in seconds
                                                                          // and frames
                stepper[i, 1] = calcuul(DT.Rows[i][1].ToString(), frate); // outtime
                stringArr[i] = DT.Rows[i][10].ToString()//subtitle
            }
            
        }

        int calcuul(string cuul, double frates )
            {
            
            double dubbel= 1000 * double.Parse(cuul.Substring(6,2))/frates;
            int milsec = (int)dubbel + 1000 * (Int32.Parse(cuul.Substring(4, 2)))
                          + 60000 * (Int32.Parse(cuul.Substring(2, 2))) + 3600000 *
                         (Int32.Parse(cuul.Substring(0, 2)));
            
            
            return milsec;
            }
Posted
Updated 4-Jul-13 4:11am
v2

1 solution

For quick key based reference to elements in memory, you can use Dictionary* [^](or it's half brother HybridDictionary[^])

* Dictionary<TKey, TValue> is found in the namespace System.Collections.Generic.
 
Share this answer
 
Comments
Jeanoff 4-Jul-13 14:03pm    
Thanks I will study Dictionary and try to use it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900