Skip to main content
added 1 character in body
Source Link
John Smith
  • 7.4k
  • 7
  • 52
  • 63

You can do it like this:

using System.IO;

static void Main(string[] args)
{
    using(var reader = new StreamReader(@"C:\test.csv"))
    {
        List<string> listA = new List<string>();
        List<string> listB = new List<string>();
        while (!reader.EndOfStream)
        {
            var line = reader.ReadLine();
            var values = line.Split(';');

            listA.Add(values[0]);
            listB.Add(values[1]);
        }
    }
}

You can do it like this:

using System.IO;

static void Main(string[] args)
{
    using(var reader = new StreamReader(@"C:\test.csv"))
    {
        List<string> listA = new List<string>();
        List<string> listB = new List<string>();
        while (!reader.EndOfStream)
        {
            var line = reader.ReadLine();
            var values = line.Split(';');

            listA.Add(values[0]);
            listB.Add(values[1]);
        }
    }
}

You can do it like this:

using System.IO;

static void Main(string[] args)
{
    using(var reader = new StreamReader(@"C:\test.csv"))
    {
        List<string> listA = new List<string>();
        List<string> listB = new List<string>();
        while (!reader.EndOfStream)
        {
            var line = reader.ReadLine();
            var values = line.Split(';');

            listA.Add(values[0]);
            listB.Add(values[1]);
        }
    }
}

You can do it like this:

using System.IO;

static void Main(string[] args)
{
    using(var fsreader = File.OpenReadnew StreamReader(@"C:\test.csv"))
    using(var reader = new StreamReader(fs))
    {
        List<string> listA = new List<string>();
        List<string> listB = new List<string>();
        while (!reader.EndOfStream)
        {
            var line = reader.ReadLine();
            var values = line.Split(';');

            listA.Add(values[0]);
            listB.Add(values[1]);
        }
    }
}

You can do it like this:

using System.IO;

static void Main(string[] args)
{
    using(var fs = File.OpenRead(@"C:\test.csv"))
    using(var reader = new StreamReader(fs))
    {
        List<string> listA = new List<string>();
        List<string> listB = new List<string>();
        while (!reader.EndOfStream)
        {
            var line = reader.ReadLine();
            var values = line.Split(';');

            listA.Add(values[0]);
            listB.Add(values[1]);
        }
    }
}

You can do it like this:

using System.IO;

static void Main(string[] args)
{
    using(var reader = new StreamReader(@"C:\test.csv"))
    {
        List<string> listA = new List<string>();
        List<string> listB = new List<string>();
        while (!reader.EndOfStream)
        {
            var line = reader.ReadLine();
            var values = line.Split(';');

            listA.Add(values[0]);
            listB.Add(values[1]);
        }
    }
}
Demonstrated that files are accessing non-managed resources and wouldn't be picked up by the garbage collector until disposed, which is what the using statement ensures.
Source Link

You can do it like this:

using System.IO;

static void Main(string[] args)
{
    using(var readerfs = new StreamReader(File.OpenRead(@"C:\test.csv"));
    using(var reader = new StreamReader(fs))
    {
        List<string> listA = new List<string>();
        List<string> listB = new List<string>();
        while (!reader.EndOfStream)
        {
            var line = reader.ReadLine();
            var values = line.Split(';');

            listA.Add(values[0]);
            listB.Add(values[1]);
        }
    }
}

You can do it like this:

using System.IO;

static void Main(string[] args)
{
    var reader = new StreamReader(File.OpenRead(@"C:\test.csv"));
    List<string> listA = new List<string>();
    List<string> listB = new List<string>();
    while (!reader.EndOfStream)
    {
        var line = reader.ReadLine();
        var values = line.Split(';');

        listA.Add(values[0]);
        listB.Add(values[1]);
    }
}

You can do it like this:

using System.IO;

static void Main(string[] args)
{
    using(var fs = File.OpenRead(@"C:\test.csv"))
    using(var reader = new StreamReader(fs))
    {
        List<string> listA = new List<string>();
        List<string> listB = new List<string>();
        while (!reader.EndOfStream)
        {
            var line = reader.ReadLine();
            var values = line.Split(';');

            listA.Add(values[0]);
            listB.Add(values[1]);
        }
    }
}
Needs an import to build
Source Link
Luke Willis
  • 8.6k
  • 4
  • 49
  • 80
Loading
Source Link
Michael M.
  • 6.8k
  • 1
  • 18
  • 18
Loading