2

I wanted to add element in array dynamically.Size is not fixed.Shall I use arraylist or array?Datatype is same.I am adding the value from database whose type is int.Then which datatype shall I used?How to add and remove a value from array or arraylist?

Jui Test
  • 2,399
  • 14
  • 49
  • 76
  • 1
    see this http://stackoverflow.com/questions/412813/when-to-use-arraylist-over-array-in-c – robasta May 28 '12 at 07:26
  • use generic list i.e `List` ex: `List` – NaveenBhat May 28 '12 at 07:28
  • You are asking three fundamentally different questions. 1) Should I use an array list or an array? 2) How do I add a value into an array list 3) How do I add values to an array? See Jon Skeet's guidlines on how to ask a good question here: http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx – Mohammed Ali May 28 '12 at 07:33

1 Answers1

1

Use Generic List instead of ArrayList to avoid overhead of type casting.

See sample

Romil Kumar Jain
  • 20,239
  • 9
  • 63
  • 92