CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2007
    Posts
    43

    how to create a List class variable with default size of "1",

    Hi I am not too sure about the syntax , since I am still very new to VB..


    So this is what I have in a class
    Code:
    Public Class DocumentDelivery
        Implements IDisposable
    
    Public Shared RenderList As New List(Of Byte()())
       
     Public Function Initialize(ByRef env As et.User.SystemCommon.Environment, ByRef errs As et.Exec.Utilities.ErrorCollection) As Boolean
    
            m_env = env
            m_errs = errs
            'set the default capacity List to 1
            RenderList.Capacity =1
            Return True
    
        End Function
    I didn't write the existing class, I am just making changes to it. I am not sure why there is no constructor. However, Intialize() is called every time a the class is created.
    Right now, I set the default capacity of the RenderList, (the class variable) to 1 in Initialize method.

    Is there a way to set the capacity outside of the initialize method? what is the syntax? Please let me know.

  2. #2
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: how to create a List class variable with default size of "1",

    Since it's a shared member, you can just access it with the fully qualified name:
    Code:
    DocumentDelivery.RenderList.Capacity = 100
    With that being said, Capacity does not actually limit the amount of items you can have in the List, it simply means that the List can hold that many items until it needs to perform a resize operation on itself. It's more of a performance setting, than a functionality setting.
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured