Results 1 to 9 of 9

Thread: Array List Add(" "c) - [Resolved]

  1. #1

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

    Array List Add(" "c) - [Resolved]

    I just came across this:

    VB Code:
    1. Dim objarrlist As New System.Collections.ArrayList
    2.  
    3.  
    4.         objarrlist.Add(" "c)

    How can we have a string followed by a c here? What exactly is this doing?
    Last edited by mendhak; Jun 4th, 2004 at 01:33 AM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    c=Char .

    so , you can only store one char type .

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This can clears it up :

    VB Code:
    1. Dim objarrlist As New System.Collections.ArrayList
    2.         objarrlist.Add(" "c)
    3.         Dim t As Type = objarrlist(0).GetType
    4.         MessageBox.Show(t.ToString)

  4. #4

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    So you mean, just one instance of a character in the entire array list?


    Can there be other options instead of c?

  5. #5

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Looks like we posted at the same time.

    I see that it converts whatever is in the string to a character.

    Can this "z"c syntax be used in other places in VB.NET or is it specific to the arraylist?

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    No , that would specify the type of the element you add . You can add char at index 0 , string at 1 , object at index 2 ..etc

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by mendhak
    Looks like we posted at the same time.

    I see that it converts whatever is in the string to a character.

    Can this "z"c syntax be used in other places in VB.NET or is it specific to the arraylist?
    Other uses for c is this (basically used with ToString method)
    VB Code:
    1. Dim c As Double = 102.01
    2. Dim s As String = c.ToString("c")
    3. MessageBox.Show(s)

    for the complete list (D,d(for dates) , c ...etc) check MSDN Help (Formatting Overview)

  8. #8

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Thanks a lot buddy.

    Who's that in your avatar? Or did that bird-flippin' baby suddenly grow old?

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by mendhak
    Who's that in your avatar? Or did that bird-flippin' baby suddenly grow old?
    No , that's just to make Brad happy . . I had a lot of troubles with admins here all because of that baby who never grows up .



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