Answered by:
Limit the amount of objects in the list

Question
-
User1824003892 posted
How do I pass the value of "_contents" into "SimpleList". I want the ability to limit the amount of objects in the list dynamically.
Public Class SimpleList Implements IList Private _contents(8) As Object Private _count As Integer Public Sub New() _count = 0 End Sub
Thursday, October 8, 2015 12:27 AM
Answers
-
User1724605321 posted
Hi Ruffone,
Your response doesn't get me to where I'd like to be. I what to be able to do "SimpleList(5)" 5 being the amount of objects that the list will holdCode below is for your reference:
Class Customer Private _contents As Object Private _count As Integer Sub New(length As Integer) Me._count = length Dim countersA(length) As Integer For intX = 0 To length countersA(intX) = 5 Next intX _contents = countersA End Sub End Class
Dim ar = New Customer(6)
Best Regards,
Nan Yu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 11, 2015 10:57 PM
All replies
-
User1724605321 posted
Hi Ruffone ,
Ruffone
How do I pass the value of "_contents" into "SimpleList".You could create a public method to pass the value to class and in the method you could do some operations like limit the amount of objects ,such as :
Class Customer Public ReadOnly Property Tags As New List(Of String) Public ReadOnly Property Name As String = "" Public ReadOnly Property File As String Sub New(file As String) Me.File = file End Sub End Class
For more details ,please refer to link below:
https://msdn.microsoft.com/en-us/library/dd293589.aspx .
Best Regards,
Nan Yu
Thursday, October 8, 2015 3:27 AM -
User1824003892 posted
Your response doesn't get me to where I'd like to be. I what to be able to do "SimpleList(5)" 5 being the amount of objects that the list will hold [Reference]
Thursday, October 8, 2015 7:58 AM -
User1724605321 posted
Hi Ruffone,
Your response doesn't get me to where I'd like to be. I what to be able to do "SimpleList(5)" 5 being the amount of objects that the list will holdCode below is for your reference:
Class Customer Private _contents As Object Private _count As Integer Sub New(length As Integer) Me._count = length Dim countersA(length) As Integer For intX = 0 To length countersA(intX) = 5 Next intX _contents = countersA End Sub End Class
Dim ar = New Customer(6)
Best Regards,
Nan Yu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, October 11, 2015 10:57 PM