locked
How CType() returns Value ? RRS feed

  • Question

  • User-1976290245 posted

    Hi,

    have a look at this code

    Dim colors() As KnownColor = CType(System.Enum.GetValues(GetType(KnownColor)), KnownColor())


    Since CType is a function that returns DataType ,But here as in the code it seems that CType() is returning array having values that is assigned to color() array. How this is happening ?

    Please explain this.

    Wednesday, July 7, 2010 7:56 AM

Answers

  • User312496708 posted

    i think  iit returns only one record which is directly added as the first record of the array in the array

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 7, 2010 8:10 AM

All replies

  • User312496708 posted

    i think  iit returns only one record which is directly added as the first record of the array in the array

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 7, 2010 8:10 AM
  • User-1976290245 posted

    No,it is returning all values present in the KnownColor Enum .How this is happening ? 

    Wednesday, July 7, 2010 8:37 AM
  • User1517224899 posted

    CTYPE converts an expression to specified datatype. Since you are trying to convert to an array. thats why its returning all values in an array.

    Wednesday, July 7, 2010 8:53 AM