Neha Alam

Neha Alam

  • NA
  • 3
  • 0

urgent c# problem

Jul 1 2009 6:13 AM

Hello.
i am a total newbie in c#. I have this assignment where i have to read data from a .txt file in an array. I have tried this code and build it. Now will u please tell me how can I see the output?? and why it isnt working??
Thank you. I am attaching my code:-
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
System.IO;
using
System.Collections;
namespace
WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
StreamReader objReader = new StreamReader("c:\\test.txt");
string sLine = "";
ArrayList arrText = new ArrayList();
while (sLine != null)
{
sLine = objReader.ReadLine();
if (sLine != null)
arrText.Add(sLine);
}
objReader.Close();
foreach (string sOutput in arrText)
Console.WriteLine(sOutput);
Console.ReadLine();
}
private void button2_Click(object sender, EventArgs e)
{
}

}

}

 

Answers (1)