no polymorphism with references ?
I am not sure why the following does not work
class obj {...}
class rocks : obj {...}
static int func(ref obj [] list) {...}
static void Main(string[] args)
{
rock []rocks = new rock[10];
{...} //initialize
func(ref rocks).ToString());
}
it returns the error: "[...] Argument '1': cannot convert from 'ref Polymorphism_ref_test.Class1.rock[]' to 'ref Polymorphism_ref_test.Class1.obj[]'"
but this does (the difference is that the argument is not a reference anymore):
class obj {...}
class rocks: obj {...}
static int func(obj [] list) {...}
static void Main(string[] args)
{
rock []rocks = new rock[10];
{...} //initialize
funk(rocks);
}
can anyone tell me why this does not work ?