Mayur M

Mayur M

  • NA
  • 1
  • 0

Typecast an ArrayList to Struct?

Mar 28 2008 3:32 AM

Hi,

I have a query regarding the struct.

1) Can a method be created in a class with a return type struct? But my return type in the method should be a ArrayList?

Please find the below sample code;

Code Snippet:

The below code is giving me an error.

public Color GetRecentColor()
        {
            if (colorCollection.Count > 0)
            {
                return (Color)colorCollection[colorCollection.Count - 1];
            }
            return null;
        }

In the above code, Color is a struct and colorCollection is an ArrayList.

Is there a solution to typecast a struct to ArrayList?

Thanks in advance,

Mayur M


Answers (1)