Click here to Skip to main content
15,903,201 members
Home / Discussions / C#
   

C#

 
QuestionDynamic cast in C# Pin
WSonck4-Oct-06 1:14
WSonck4-Oct-06 1:14 
AnswerRe: Dynamic cast in C# Pin
User 66584-Oct-06 1:20
User 66584-Oct-06 1:20 
GeneralRe: Dynamic cast in C# Pin
WSonck4-Oct-06 1:33
WSonck4-Oct-06 1:33 
AnswerRe: Dynamic cast in C# Pin
Colin Angus Mackay4-Oct-06 1:37
Colin Angus Mackay4-Oct-06 1:37 
GeneralRe: Dynamic cast in C# Pin
WSonck4-Oct-06 4:19
WSonck4-Oct-06 4:19 
AnswerRe: Dynamic cast in C# Pin
f*** YOU4-Oct-06 5:00
f*** YOU4-Oct-06 5:00 
GeneralRe: Dynamic cast in C# Pin
Colin Angus Mackay4-Oct-06 5:50
Colin Angus Mackay4-Oct-06 5:50 
GeneralRe: Dynamic cast in C# Pin
LongRange.Shooter4-Oct-06 6:38
LongRange.Shooter4-Oct-06 6:38 
Colin Angus Mackay wrote:
How do you determine whether the null after the cast was because of an invalid cast, or because the reference was null in the first place?


if ( originalObject == null )
{
      ... action ...
}
else
{
    NewObjectType newObj = originalObject as NewObjectType;
    if ( newObj == null )
    {
           ... alternative action ...
    }
}


The approach listed above, BTW, is used in some framework code to determine if a specific object is IDisposable before committing to an action.
GeneralRe: Dynamic cast in C# Pin
Colin Angus Mackay4-Oct-06 7:37
Colin Angus Mackay4-Oct-06 7:37 
GeneralRe: Dynamic cast in C# Pin
LongRange.Shooter4-Oct-06 14:20
LongRange.Shooter4-Oct-06 14:20 
GeneralRe: Dynamic cast in C# Pin
Colin Angus Mackay4-Oct-06 21:31
Colin Angus Mackay4-Oct-06 21:31 
QuestionBizzare request Pin
Liron Hirsch4-Oct-06 0:59
Liron Hirsch4-Oct-06 0:59 
JokeRe: Bizzare request Pin
Gael Fraiteur4-Oct-06 1:52
Gael Fraiteur4-Oct-06 1:52 
GeneralRe: Bizzare request Pin
Liron Hirsch4-Oct-06 2:08
Liron Hirsch4-Oct-06 2:08 
QuestionRe: Bizzare request Pin
David Crow4-Oct-06 5:37
David Crow4-Oct-06 5:37 
AnswerRe: Bizzare request Pin
Liron Hirsch4-Oct-06 6:12
Liron Hirsch4-Oct-06 6:12 
AnswerAnyone ?? Pin
Liron Hirsch4-Oct-06 3:29
Liron Hirsch4-Oct-06 3:29 
GeneralRe: Anyone ?? Pin
Dan Neely4-Oct-06 3:37
Dan Neely4-Oct-06 3:37 
GeneralRe: Anyone ?? Pin
led mike4-Oct-06 5:19
led mike4-Oct-06 5:19 
GeneralRe: Anyone ?? Pin
Dan Neely4-Oct-06 5:24
Dan Neely4-Oct-06 5:24 
GeneralRe: Anyone ?? Pin
led mike4-Oct-06 5:30
led mike4-Oct-06 5:30 
AnswerRe: Bizzare request Pin
Andrew Rissing4-Oct-06 4:27
Andrew Rissing4-Oct-06 4:27 
GeneralRe: Bizzare request Pin
benjymous4-Oct-06 4:54
benjymous4-Oct-06 4:54 
AnswerRe: Bizzare request Pin
Eric Dahlvang4-Oct-06 5:32
Eric Dahlvang4-Oct-06 5:32 
QuestionCreating Objects by program Pin
Harikrk4-Oct-06 0:33
Harikrk4-Oct-06 0:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.