Reputation: 1987
When I use this line, I get an error:
tradesThisBar=new List<Traid>;
error: A new expression requires (), [], or {} after type
How do I initialize it? I initialize it in the declaration but I need to reset it.
also, will this line work?:
if (tradesThisBar!=null){}
Upvotes: 2
Views: 141
Reputation: 103358
As the error has specified, add ()
after your type:
tradesThisBar=new List<Traid>();
Regarding the 2nd snippet of code, the code you enter into the {}
will only be ran if tradesThisBar
is not null
.
In terms of whether it will "work" depends on what you wish for it to do. But it will compile.
Upvotes: 4
Reputation: 21004
You need to call the constructor:
tradesThisBar = new List<Traid>();
If you want to reset it:
tradesThisBar = null;
Upvotes: 1