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 ?

bilnaadRank #2,169 · 655 reputationPosted Oct 29, 2004, 2:24 AM EDT
loogel17 reputationPosted Oct 29, 2004, 12:12 PM EDT
bilnaadRank #2,169 · 655 reputationPosted Oct 29, 2004, 12:57 PM EDT
loogel17 reputationPosted Oct 29, 2004, 2:53 PM EDT
loogel17 reputationPosted Oct 29, 2004, 2:55 PM EDT
bilnaadRank #2,169 · 655 reputationPosted Oct 29, 2004, 3:22 PM EDT
Andrzej WegierskiRank #1,729 · 877 reputationPosted Oct 29, 2004, 10:06 PM EDT
loogel17 reputationPosted Oct 29, 2004, 11:03 PM EDT
bilnaadRank #2,169 · 655 reputationPosted Oct 30, 2004, 7:22 AM EDT
loogel17 reputationPosted Oct 30, 2004, 12:43 PM EDT
kuantanzai-sf2 reputationPosted Nov 17, 2004, 8:45 AM EST
bilnaadRank #2,169 · 655 reputationPosted Nov 17, 2004, 10:43 AM EST