Results 1 to 3 of 3

Thread: initializing a 2D array?

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    initializing a 2D array?

    Apparently when you declare a 2D array you can't initialize the size of the second dimension. This what I'm doing right now...
    PHP Code:
                byte[][] intensityVals = new byte[height][];
    for (
    int i=0i<heighti++)
          
    intensityVals[i] = new byte[width]; 
    isn't there a better or shorter way?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    VB Code:
    1. [b]Single-dimensional array[/b]
    2. int[] numbers = new int[5];
    3.  
    4. [b]Multidimensional array[/b]
    5. string[,] names = new string[5,4];
    6.  
    7. [b]Array-of-arrays (jagged array)[/b]
    8. byte[][] scores = new byte[5][];
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Memnoch1207
    VB Code:
    1. [b]Single-dimensional array
    2. int[] numbers = new int[5];
    3.  
    4. [b]Multidimensional array[/b]
    5. string[,] names = new string[5,4];
    6.  
    7. [b]Array-of-arrays (jagged array)[/b]
    8. byte[][] scores = new byte[5][];
    [/B]
    hmm interesting thank you! second one was what I was looking for...

    umm I still dont understand the difference between declaring it like [x][y] versus [x,y].... both seem to work the same? hmm (is it just that they work the same but are different structurally?)

    excuse my idiot-ness btw
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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