I have a class called cEspecie like this
public class cEspecie
{
private string name;
private int lifetime;
private int movility;
private int deadto;
private int type;
public string Name
{
get
{
return name;
}
set
{
name= value;
}
}
public int Type
{
get
{
return type;
}
set
{
type = value;
}
}
public int LifeTime
{
get
{
return lifetime;
}
set
{
lifetime= value;
}
}
public int Movility
{
get
{
return movility;
}
set
{
movility = value;
}
}
public int DeadTo
{
get
{
return deadto;
}
set
{
deadto = value;
}
}
}
I store some data in a list called
List<cEspecie> list = new List<cEspecie>() {
new cEspecie("Wolf", 100, 10, 0, 0)
new cEspecie("Rabiit", 100, 100, 1, 1),
new cEspecie("Lion", 200, 10, 2, 2),
new cEspecie("Tiger", 300, 10, 3, 3),
};
In one of the process of my program i store all the data inside a text file using this:
using (StreamWriter sr = new StreamWriter(@"../../Archives/TextFilecEspecie.txt"))
{
foreach (var item in list)
{
sr.WriteLine(item.Name);
sr.WriteLine(item.Type);
sr.WriteLine(item.Movility);
sr.WriteLine(item.LifeTime);
sr.WriteLine(item.DeadTo);
}
sr.Close();
}
the result inside "TextFilecEspecie.txt" was this:
Wolf
100
10
0
0
Rabiit
100
100
1
1
Lion
200
10
2
2
Tiger
300
10
3
3
now my real, real problem is ... How can i get back the same data to store it in the same list? I'm using c# and wpf and i really dont find an answer.