Change mthods parameters names

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
 
M

Martin Honnen

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.
 
P

Peter Duniho

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top