Results 1 to 5 of 5

Thread: question related to array

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    266

    question related to array

    is there any way to find out that how many nodes of an array are filled with some value

    for example if i have an array like

    String[] strarr = new string[10];


    and i have put some values in this array using some loop ... but i dnt know each time how many values would b moved in the array

    now i wanna read the array to that point where the last value is stored

    can i know this thing
    in c#
    plz help
    Last edited by noshaba; Sep 24th, 2006 at 11:34 PM.

  2. #2
    Fanatic Member
    Join Date
    May 2001
    Posts
    837

    Re: question related to array

    Use an ArrayList instead in VS2003, or a List<string> in VS2005. It dynamically resizes so you don't have to keep track of how many nodes are used.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    266

    Re: question related to array

    ok thnx but can u plz help me how could i declare List and fill it run time
    sorry for bothering as m very new in C#

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: question related to array

    Don't use the ArrayList in either case. You can use List<string> in 2005 as suggested, or you can use a Specialized.StringCollection in any version. Let Intellisense guide you.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: question related to array

    VB Code:
    1. Dim sc As New StringCollection()
    2. sc.Add("something")

    There's also the option to use sc.Insert, which lets you insert at a specific position.

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