Sunday 31 July 2016

Hiding GetHashCode/Equals/ToString/GetType from Class

I get annoyed of these (by design) methods that appear in any class, because each class inherit from Object class, and they are part of the Object class.

Use This Code

#Region "Hide System Object"
    EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>
    <Browsable(False)> _
    Public  Shared Function Equals(ByVal obj As ObjectAs Boolean
        Return Nothing ' MyBase.Equals(obj)
    End Function

    EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)> _
    <Browsable(False)> _
    Public Function GetHashCode() As Integer
        Return MyBase.GetHashCode
    End Function

    EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)> _
    <Browsable(False)> _
    Public Function [GetType]() As Type
    End Function

    EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)> _
    <Browsable(False)> _
    Public Overridable Function ToString() As [String]
        Return [GetType]().ToString()
    End Function

    EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)> _
    <Browsable(False)> _
    Public Shared Function ReferenceEquals(objA As ObjectobjB As ObjectAs Boolean 
    End Function

#End Region




No comments:

Post a Comment