Reputation: 1
public class E
{
public static List<Tranzactie> tranzactie = new List<Tranzactie>();
}
public class Tranzactie
{
public string name;
public string contract;
}
static void main()
{
where i have a method with a loop that parses a.txt file
and passes extracted values to Tranzactie
}
In class E there is a list i want to populate with values extracted from parsing a txtfile in Main. The data collected in Main fills fields from class Tranzactie.
How do i put the values passed to "Tranzactie" into the list found in class E?
Upvotes: 0
Views: 31
Reputation: 4889
Well, somewhere in your loop, you'll need to:
new Tranzactie
objectname
and contract
fieldsList<Tranzactie>
So, here's the code to do just that part:
// assuming you have variables "name" and "contract" that hold necessary data
var tranzactie = new Tranzactie()
{
name = name,
contract = contract
};
E.tranzactie.Add(tranzactie);
As an aside, I would rename the List<Tranzactie>
in class E
to tranzactii
, because it represents multiple transactions - a collection - so plural form of the word is typically preferred.
Upvotes: 1