Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > BOOK: Professional .NET 2.0 Generics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional .NET 2.0 Generics
This is the forum to discuss the Wrox book Professional .NET 2.0 Generics by Tod Golding; ISBN: 9780764559884
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional .NET 2.0 Generics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 19th, 2007, 04:09 AM
Registered User
Join Date: Aug 2007
Location: , , Russia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Guidelines Item 3: Replace System.Type with Type

Hello everyone. Can anyone point me what is a big deal in 3rd guidelines item? Tod advices to use:
public T FindPerson<T>(T personType, int id) {}
instead of
public object FindPerson(Type personType, int id) {}
The thing I can't understand is why is the first piece of code is better. Let's imagine we have a class named PersonFinder and it has the FindPerson method. So what would be the usage of this method? It will look something like this:
PersonFinder finder = new PersonFinder();
Employee employee = new Employee();
finder.FindPerson<Employee>(employee, 1);
See? I can't call method FindPerson if I don't provide an instance of the Employee class. But that's stupid! I can understand the following signature, without generic type:
public T FindPerson<T>(int id) {}
But there is no big difference for me where the type parameter will be: in method parameter or signature.
Can anyone point me what I missed?

P.S. By the way, the rest of the book is great :)

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
An unhandled exception of type 'System.Data.SqlCli BB VB.NET 2002/2003 Basics 5 February 21st, 2014 10:22 AM
Reading the type of file system scoobie Java Basics 5 August 20th, 2009 02:35 AM
unhandled exception of type 'System.Net.WebExcepti booksnore2 C# 0 June 26th, 2004 07:26 AM

All times are GMT -4. The time now is 09:11 PM.

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