Results 1 to 3 of 3

Thread: Overload properties

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    6

    Overload properties

    Hi all,

    I've got a problem overloading properties and I don't know why!

    If I need the same property with different arguments VB.NET let me do

    1)
    Public Property A() As Integer
    Public Property A(ByVal b As Boolean) As Integer
    Public Property A(ByVal c As String) As Integer

    2)
    Public Override Property A() As Integer
    Public Override Property A(ByVal b As Boolean) As Integer
    Public Override Property A(ByVal c As String) As Integer

    These two syntaxes are the same?

    Why if I call Class1.A() from a C# code sometimes I get just A() or A(b) or A(c), sometimes A(), A(b) and A(c) (how I expect!) and sometimes I must call the internal name get_A()/set_A(), get_A(b)/set_A(b)...

    This is too strange to me!

    Cya

  2. #2
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Don't completely understand the question.

    Class2 should be inherting Class1. Also, in class one you should use the syntax to let the compiler know that property X is overridable using the "Overridable" keyword.
    Please rate my post.

  3. #3
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    I don't understand the question either, but another possibility is...


    When you override a method from a base class in a derived class. The type of object you create will determine which class you actually call. If you create a base class object, you will call the base class method. If you create a derived class object, you will call the derived class method.

    This may or may not be what you're looking for, but I took a shot.
    That which does not kill us, only makes us stronger.

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