CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Array in C#

  1. #1
    Join Date
    Feb 2002
    Posts
    295

    Array in C#

    What is the equivalent code for this?

    Code:
    private procList As New ArrayList()
    I have a problem in accessing the array list in c#.

    please help.

    thank you.

  2. #2
    Join Date
    Feb 2008
    Posts
    79

    Re: Array in C#

    I would use:

    List<type> x = new List<type>();
    eg. List<string> x = new List<string>();

    ...

    or

    ArrayList al = new ArrayList();

    or

    string[] sa = new string[];
    Cheers,
    Jon

  3. #3
    Join Date
    Feb 2002
    Posts
    295

    Re: Array in C#

    Quote Originally Posted by jon.borchardt
    I would use:

    List<type> x = new List<type>();
    eg. List<string> x = new List<string>();

    ...

    or

    ArrayList al = new ArrayList();

    or

    string[] sa = new string[];
    It doesn't work!
    Coz i want that to implement it here.

    Code:
                
    private procList = new ArrayList();
    
    if ((procList != null))
    {
                    int i;
                    for (i = 0; i <= procList.Count - 1; i++)
                    {
                        KingLeon.Help.CloseHelp((Diagnostics.Process)procList(i));
                    }
    }
    How would I do that?

  4. #4
    Join Date
    Feb 2008
    Posts
    79

    Re: Array in C#

    I need more info
    why cant you use a generic?
    it is because the api requires an arraylist?

    if so, why can you not just use an arraylist?

    what is not working?
    Cheers,
    Jon

  5. #5
    Join Date
    Nov 1999
    Location
    Denmark
    Posts
    260

    Re: Array in C#

    KingLeon.Help.CloseHelp((Diagnostics.Process)procList(i));
    should be
    KingLeon.Help.CloseHelp((Diagnostics.Process)procList[i]);

    problem is that you are using some vb syntax thing

  6. #6
    Join Date
    Apr 2006
    Posts
    220

    Re: Array in C#

    Quote Originally Posted by pre_wreck
    What is the equivalent code for this?

    Code:
    private procList As New ArrayList()
    I have a problem in accessing the array list in c#.

    please help.

    thank you.
    Equivalent is
    Code:
    private ArrayList procList = new ArrayList();
    and you will use it as

    Code:
    procList.Add(someObject);

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