Change mthods parameters names

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

Can I change the parameters names when overriding a method?

Something like instead of using the original:
public override int GetErrors(int listIndex, int listSize)

I would use:

public override int GetErrors(int index, int size)

Is this ok?

Thanks,
Miguel
 
shapper said:
Can I change the parameters names when overriding a method?

Something like instead of using the original:
public override int GetErrors(int listIndex, int listSize)

I would use:

public override int GetErrors(int index, int size)

Is this ok?

As far as I am aware that is allowed so it will compile.
 
Hello,

Can I change the parameters names when overriding a method?

Something like instead of using the original:
public override int GetErrors(int listIndex, int listSize)

I would use:

public override int GetErrors(int index, int size)

Is this ok?

It's not illegal. But it's not necessarily a good idea either. The IDE
will display different argument names depending on what type is being used
to reference the method, which could be a point of maintenance confusion.

You may also want to test such a change with the VS2010 beta, where in C#
4.0 you can call a method using named arguments. I haven't tried it
myself, but I suspect that you'll find a similar declaration-based
disparity in terms of the names available at the call site.

Pete
 
Back
Top