Allows CLR more than 2 accessors for a property?

  • Thread starter Thread starter cody
  • Start date Start date
C

cody

Does the clr allow more than one set and one get method for a property? Is
it possible to use overloading for example set_Color(int c), set_Color(Color
c)?

from msdn:

PropertyInfo.GetAccessors Method ()

Return Value
An array of MethodInfo objects that reflect the public get, set, *and other
accessors* of the property reflected by the current instance, if found;
otherwise, this method returns an array with zero (0) elements.

what is meant with "other accessors" here?
 
Does the clr allow more than one set and one get method for a property? Is
it possible to use overloading for example set_Color(int c),
set_Color(Color
c)?
Not possible, there will always be only one setter for the same property
with one argument this is because when you overload a property you need two
different signatures (does not include return type).
what is meant with "other accessors" here?
No idea but if you look at the documentation for C# there are not other
modifiers.

Gabriel Lozano-Morán
 
Does the clr allow more than one set and one get method for a property?
No


Is
it possible to use overloading for example set_Color(int c), set_Color(Color
c)?

Yes, but only one of those method can be the setter.

what is meant with "other accessors" here?

In languages that allow it, such as ILAsm, you can associate an
arbitrary number of other methods to a property. But there's still at
most one getter and one setter.



Mattias
 
Back
Top