|
-
April 16th, 2009, 02:47 AM
#11
Re: Questions about casting object types...
 Originally Posted by BigEd781
Well, it may cause an exception at runtime of 'Obj' is not an Employee object under the hood. You would be better served using a safe cast on reference types:
Code:
object o = new Employee();
// some time later
Employee e = o as Employee;
if ( e != null )
{
// the cast succeeded
}
else
{
// the cast failed, 'o' is not of the type 'Employee'
}
Understood. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|