0

I have declared an ArrayList like this

Dim List1 As ArrayList = New ArrayList

Adding a ListItem to it

Dim Item As String = ""
List1.Add(New ListItem(Item))

Is there is any limit how many characters the ListItem can contain?

2
  • 2
    Use a strongly typed List(Of String) instead of an ArrayList. "Is there is any limit how many characters Item can contains." Your memory is the limit. Commented Sep 24, 2012 at 12:02
  • Not that I am aware. Is this a functionality that you want to have? Commented Sep 24, 2012 at 12:03

1 Answer 1

2

"Is there is any limit how many characters Item can contains." It's limited by the limit of the length of a String and your memory.

The theoretical limit may be 2,147,483,647, but the practical limit is nowhere near that. Since no single object in a .Net program may be over 2GB and the string type uses unicode (2 bytes for each character), the best you could do is 1,073,741,823, but you're not likely to ever be able to allocate that on a 32-bit machine.

https://stackoverflow.com/a/140749/284240

Apart from that, always use a strongly typed List(Of ListItem) instead of an ArrayList.

Dim List1 = New List(Of ListItem)
List1.Add(New ListItem("Foo1"))

c# When should I use List and when should I use arraylist?

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.