Complete set: Intro to C - Bill Buchanan
Complete set: Intro to C - Bill Buchanan
Complete set: Intro to C - Bill Buchanan
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Program 3.8: Program3_8_ArrayListGenerateDataWithCSVFindAverage<br />
namespace ConsoleApplication2<br />
{<br />
using System;<br />
using System.Collections; // required for ArrayList<br />
using System.IO; // required for File I/O<br />
class ArrayExample02<br />
{<br />
static void fillData(ArrayList v)<br />
{<br />
int i=0;<br />
FileInfo theSourceFile = new FileInfo("..\\..\\test.csv");<br />
StreamReader reader = theSourceFile.OpenText();<br />
string text;<br />
do<br />
{<br />
text=reader.ReadLine();<br />
if (text==null) break;<br />
foreach (string substring in text.Split(','))<br />
{<br />
v.Add(Convert.ToDouble(substring));<br />
i++;<br />
}<br />
} while (text != null);<br />
}<br />
reader.Close();<br />
static void showData(ArrayList v)<br />
{<br />
int i;<br />
for (i=0;i