Wrox Programmer Forums
|
BOOK: MCSD Certification Toolkit (Exam 70-483): Programming in C#
This is the forum to discuss the Wrox book MCSD Certification Toolkit (Exam 70-483): Programming in C# by Tiberiu Covaci, Rod Stephens, Vincent Varallo, Gerry O'Brien; ISBN: 978-1-118-61209-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: MCSD Certification Toolkit (Exam 70-483): Programming in C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 30th, 2014, 08:53 AM
Registered User
 
Join Date: Jun 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 8, Question 4

This questions asks which syntax can be used to determine an objects type.

The answer key says the correct answer is d. Is there any reason why the correct answer is not a or d?

Answer a is
Type myType = typeof(myParameter);

Answer d is
Type myType = myParameter.GetType();
 
Old July 2nd, 2014, 11:39 PM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

The parameter to typeof must be a type not an object. For example, the following code creates a Type object that represents the Person class:

Code:
Type personType = typeof(Person);
In contrast, if bob is a Person object, you can't do this:

Code:
Type bobType = typeof(bob);
You could use typeof if you knew what type of object bob was, but the question is about determining the object's type so that won't help you much.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Misleading question: Chapter 3, Question 15 rupe120 BOOK: MCSD Certification Toolkit (Exam 70-483): Programming in C# 0 July 17th, 2013 09:10 AM
Chapter 1 Question JohnNWFS BOOK: Beginning Android 4 Application Development 2 June 24th, 2012 10:38 AM
Question on Chapter 5 chester8 BOOK: Expert Access 2007 Programming ISBN 978-0-470-17402-9 0 December 14th, 2011 12:18 AM
Chapter 4 question davidle1234 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 January 18th, 2007 12:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.