casting custom classes

Discussion in 'ASP .Net Web Controls' started by Sam, Jul 26, 2005.

  1. Sam

    Sam Guest

    Namespace system.web.ui
    Public Class ReplacableControlCollection
    Inherits ControlCollection
    End Class
    End Namespace
    -------------------------------------------------------

    Public Shadows ReadOnly Property controls() As
    ReplacableControlCollection
    Get
    Return MyBase.Controls
    End Get
    End Property
    -------------------------------------------------------

    Error:
    System.InvalidCastException: Unable to cast object of type
    'System.Web.UI.ControlCollection' to type
    'System.Web.UI.ReplacableControlCollection'.
    Line 60: Return MyBase.Controls

    -------------------------------------------------------

    how do i cast this?
    the only thing difference in ReplacableControlCollection from the
    original ControlCollection is an added sub "replace()".

    Sam.
    Sam, Jul 26, 2005
    #1
    1. Advertising

  2. Sam

    sam Guest

    whoah dude,

    You are trying to cast *down* the inheritence chain. You can't do that
    ;)
    sam, Jul 26, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kevin
    Replies:
    11
    Views:
    5,782
    Andrew McDonagh
    Jan 8, 2005
  2. Replies:
    8
    Views:
    1,343
    Victor Bazarov
    Jan 7, 2006
  3. Wally Barnes
    Replies:
    3
    Views:
    509
    Wally Barnes
    Nov 20, 2008
  4. Sosuke

    Up casting and down casting

    Sosuke, Dec 20, 2009, in forum: C++
    Replies:
    2
    Views:
    547
    James Kanze
    Dec 20, 2009
  5. Sam

    casting custom classes

    Sam, Jul 26, 2005, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    109
Loading...

Share This Page