Exemple #1
0
        public AAPL(string filename)
        {
            StreamReader reader  = new StreamReader(filename);
            string       line    = "";
            AAPL         newAAPL = null;

            while ((line = reader.ReadLine()) != null)
            {
                line = line.Trim();
                if (line.Length > 0)
                {
                    if (line.StartsWith("AAPL"))
                    {
                        string dateStr = line.Substring(line.IndexOf(",") + 1);
                        date    = DateTime.Parse(dateStr);
                        newAAPL = new AAPL();
                        aapls.Add(newAAPL);
                        newAAPL.date = date;
                    }
                    else
                    {
                        string[] splitArray = line.Split(new char[] { ':' });
                        switch (splitArray[0])
                        {
                        case "Open":
                            newAAPL.open = decimal.Parse(splitArray[1]);
                            break;

                        case "Close":
                            newAAPL.close = decimal.Parse(splitArray[1]);
                            break;

                        case "Low":
                            newAAPL.low = decimal.Parse(splitArray[1]);
                            break;

                        case "High":
                            newAAPL.high = decimal.Parse(splitArray[1]);
                            break;

                        case "Volume":
                            newAAPL.volume = int.Parse(splitArray[1]);
                            break;
                        }
                    }
                }
            }
        }
Exemple #2
0
 static void Main(string[] args)
 {
     AAPL aapl = new AAPL(FILENAME);
 }