RE: Testing for a type at runtime.
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 05/04/04
- Next message: Majed: "Re: writing to the event log from a service"
- Previous message: Jon Skeet [C# MVP]: "Re: atomic operation"
- In reply to: Kevin Burton: "RE: Testing for a type at runtime."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 4 May 2004 18:39:26 +0100
Kevin Burton <anonymous@discussions.microsoft.com> wrote:
> I need the cast because C# methods require it. Again using my example
> A and B inherit from C.
>
> C obj = GenerateReply()
> . . .
> ProcessReply(obj); // Compiler will not allow this. A cast must be done.
> . . .
> ProcessReply(A obj)
> {
> }
>
> I cannot call ProcessReply with C even though it may be an A. I have
> to cast it to an A and the method that I would like to use is 'as'.
The reason you need to do that is for the C# compiler though - in other
words, for compile-time reasons. Could you give an example of how you
want to use it at run time instead?
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Majed: "Re: writing to the event log from a service"
- Previous message: Jon Skeet [C# MVP]: "Re: atomic operation"
- In reply to: Kevin Burton: "RE: Testing for a type at runtime."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|