Re: Why are there no covariant return types?
From: Stefan Slapeta (stefan_nospam__at_slapeta.com)
Date: 07/02/04
- Next message: Stefan Slapeta: "Re: Why are there no covariant return types?"
- Previous message: Dean Bortell: "RE: Problem calling .focu() when in worker thread."
- In reply to: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Why are there no covariant return types?"
- Next in thread: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Why are there no covariant return types?"
- Reply: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Why are there no covariant return types?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 02 Jul 2004 11:35:57 +0200
Stoitcho Goutsev (100) [C# MVP] wrote:
> Yeah, besides the fact that theoretically you don't know the type of the
> object, which Clone methods you call.
>
> And again in theory one should go with the most generic base type and then
> do the conversion.
>
In theory, you should avoid any cast if possible because every cast is a
potential runtime error!
And here - *with* covariant return types - you *for sure* know what
class you are dealing with *and* you can avoid any cast.
ArrayList original;
ArrayList copy = original.Clone();
Stefan
- Next message: Stefan Slapeta: "Re: Why are there no covariant return types?"
- Previous message: Dean Bortell: "RE: Problem calling .focu() when in worker thread."
- In reply to: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Why are there no covariant return types?"
- Next in thread: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Why are there no covariant return types?"
- Reply: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Why are there no covariant return types?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|