Created
January 13, 2017 07:32
-
-
Save boldijar/5b3d664946bcc6d5443e30bd50eb2239 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace test | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<Intrebare> intrebari = new List<Intrebare>(); | |
// citim din fisierul in.txt, se afla in folderul proiectului/bin/debug, acolo il creezi | |
StreamReader reader = new StreamReader("in.txt"); | |
String line; | |
// citim fiecare linie | |
while ((line = reader.ReadLine()) != null) | |
{ | |
String[] columns = line.Split('|'); | |
int id = Convert.ToInt32(columns[0]); | |
String enunt = columns[1]; | |
String raspuns = columns[2]; | |
// adaugam intrebarea | |
intrebari.Add(new Intrebare(id,enunt,raspuns)); | |
} | |
// afisam fiecare intrebare | |
intrebari.ForEach(item => | |
{ | |
Console.WriteLine(item.ToString()); | |
}); | |
// punem si asta ca sa nu se inchida singura consola la finalu executiei | |
Console.Read(); | |
} | |
} | |
class Intrebare | |
{ | |
public int id; | |
public String enunt; | |
public String raspuns; | |
// constructor default | |
public Intrebare() | |
{ | |
} | |
// constructor cu variabilele | |
public Intrebare(int id,String enunt,String raspuns) | |
{ | |
this.id = id; | |
this.enunt = enunt; | |
this.raspuns = raspuns; | |
} | |
// suprascriem metoda ToString, sa ne dea variabilele separate de spatiu | |
public override string ToString() | |
{ | |
return id + " " + enunt + " " + raspuns; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment