CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    28

    creating an array of colors

    ok this is weird, im trying to create an array of colors. approach 2 doesn't work and i do not know why

    Code:
    'approach 1: works
    Dim list As Color() = New Color() {Color.FromArgb(255, 0, 0), Color.FromArgb(0, 255, 0), Color.FromArgb(0, 0, 255)}
    Code:
    'approach 2: fails.. why?
    Dim list() As Color = New Color() {Color.FromArgb(255, 0, 0), Color.FromArgb(0, 255, 0), Color.FromArgb(0, 0, 255)}
    if instead i wish to create an array of strings, both approach works, that's weird

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: creating an array of colors

    [Moved to VB.NET]

    I tried both ways and it is working. If you are trying to use both of them together in the same block then you will receive an error saying that "local variable is already declared in the same block".
    Last edited by Shuja Ali; October 25th, 2009 at 11:54 AM. Reason: Added a reply.

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: creating an array of colors

    Can't see why any of those would fail, didn't fail with 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