I have the following abstract base class:
public abstract class HashBase
{
public abstract byte[] Hash(byte[] value);
}
And then I go ahead and implement that class:
public class CRC32Hash : HashBase
{
public override byte[] Hash(params byte[] value)
{
return SomeRandomHashCalculator.Hash(value);
}
}
Compile...and it works!
You can take a look to C# language specification §7.5.3 (overload)
Briefly, i think override keyword is used to redefine an implementation, not the parameters. You cant override args, the args must be the same of abstraction (im thinking about the liskov substitution principle application here).
Params is totally a syntaxic sugar, it is strictly equivalent to a simple array. It's just more easy to call in certain cases, avoiding array casting; compilator makes the work for you during the method call.
Note that in C# 6, params is going to be compatible with IEnumerable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With