Issues with System.Collections.Generic.List

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Susan

    #1

    Issues with System.Collections.Generic.List

    I have an issue with the System.Collecti ons.Generic.Lis t that I can't
    find anywhere else...

    My website suddenly starts giving off System.IndexOut OfRangeExceptio n:
    Index was outside the bounds of the array. errors in a spot that I
    cannot figure out the problem. It will work all day, then suddenly
    start giving off the error, which makes quite a bit fail.

    The error (System.IndexOu tOfRangeExcepti on: Index was outside the
    bounds of the array. ) occurs on line 14, which makes absolutely no
    sense. Any ideas? Like I said, it will work all day, then just start
    failing for what looks like no reason... Thanks

    My code:
    1 Public Enum ImageSize
    2 Small = 10
    3 Medium = 20
    4 Thumbnail = 30
    5 Zoom = 40
    6 Large = 50
    7 End Enum
    8
    9 Private Shared _imageSizes As List(Of ImageSize) = Nothing
    10 Private Shared Function GetImageSizes() As List(Of ImageSize)
    11
    12 If _imageSizes Is Nothing Then
    13 _imageSizes = New List(Of ImageSize)
    14 _imageSizes.Add (ImageSize.Smal l)
    15 _imageSizes.Add (ImageSize.Medi um)
    16 _imageSizes.Add (ImageSize.Thum bnail)
    17 _imageSizes.Add (ImageSize.Zoom )
    18 _imageSizes.Add (ImageSize.Larg e)
    19 End If
    20
    21 Return _imageSizes
    22 End Function

Working...