Results 1 to 1 of 1

Thread: [RESOLVED] Hide Base Methods In An Inherited Class

  1. #1

    Thread Starter
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Resolved [RESOLVED] Hide Base Methods In An Inherited Class

    I'm trying to hide base methods in an inherited class, and I am using a method where a wrapper is used to return an interface of methods that are seen, like so:

    vb.net Code:
    1. Public Class MyWrapper
    2.  
    3.     Private _MyStringList As MyStringList
    4.  
    5.     Public Sub New()
    6.         Me._MyStringList = New MyStringList
    7.     End Sub
    8.  
    9.     Private _List As IMyListFunctions
    10.     Public Property List() As IMyListFunctions
    11.         Get
    12.             Return _List
    13.         End Get
    14.         Set(ByVal value As IMyListFunctions)
    15.             _List = value
    16.         End Set
    17.     End Property
    18.  
    19.     Private Class MyStringList
    20.         Inherits List(Of String)
    21.         Implements IMyListFunctions
    22.  
    23.         Public Overloads Sub Add(ByVal item As String) Implements IMyListFunctions.Add
    24.             MyBase.Add(item)
    25.         End Sub
    26.  
    27.         Public Overloads Function Contains(ByVal item As String) As Boolean Implements IMyListFunctions.Contains
    28.             Return MyBase.Contains(item)
    29.         End Function
    30.  
    31.     End Class
    32.  
    33.     Public Interface IMyListFunctions
    34.         Sub Add(ByVal item As String) 'Allow Add
    35.         Function Contains(ByVal item As String) As Boolean 'Allow Contains
    36.     End Interface
    37.  
    38. End Class

    And what I am basically wondering is if there is an easier way to do this. Is there some sort of Compile attribute I can apply instead?

    EDIT: The best way to do this (Microsoft does this) is to use these Attributes:

    vb.net Code:
    1. <System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)> _
    2. APropertyOrMethod

    Overtop of a Method or Property, then if they are called throw NotSupportedExceptions.
    Last edited by ForumAccount; Aug 17th, 2009 at 06:46 PM.

Tags for this Thread

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