Reputation: 111
I want to create a list with 11 entries, but List.Count
resets to zero after this code.
There are no entries added to the list. What is wrong?
List<Animation> animations = new List<Animation>();
animations[0] = new Animation(new List<Rectangle>(10),
Content.Load<Texture2D>("pictures"),
TimeSpan.FromSeconds(2),
Animation.Animationsablaeufe.vorrück);
Upvotes: 0
Views: 245
Reputation: 13198
List<Animation> animations = new List<Animation>(); // count should be 0
animations.Add(new Animation(...)); // count should be 1
animations.Add(new Animation(...)); // count should be 2
// etc...
You can also use the following notation, which is equivalent:
List<Animation> animations = new List<Animation>
{
new Animation(...),
new Animation(...),
new Animation(...),
new Animation(...),
...
new Animation(...)
};
Upvotes: 2
Reputation: 3449
List<Animation> Animations = new List<Animation>();
Animations.Add(new Animation);
Animations.Count();
Upvotes: 0