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?

3
  • 1
    see this stackoverflow.com/questions/412813/… Commented May 28, 2012 at 7:26
  • use generic list i.e List<Type> ex: List<string> Commented May 28, 2012 at 7: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: msmvps.com/blogs/jon_skeet/archive/2010/08/29/… Commented May 28, 2012 at 7:33

1 Answer 1

1

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

See sample

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.