Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleUI
- {
- class Program
- {
- static void Main(string[] args)
- {
- string filePath = @"C:\Demos\Test.txt";
- List<Person> people = new List<Person>();
- List<string> lines = File.ReadAllLines(filePath).ToList();
- foreach(string line in lines)
- {
- string[] entries = line.Split(',');
- Person newPerson = new Person();
- newPerson.FirstName = entries[0];
- newPerson.LastName = entries[1];
- newPerson.Email = entries[2];
- people.Add(newPerson);
- }
- foreach (var person in people)
- {
- Console.WriteLine($"{person.FirstName} {person.LastName}: {person.Email}");
- }
- Console.ReadLine();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleUI
- {
- class Person
- {
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string Email { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment