Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 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 May 5th, 2006, 04:19 PM
jminatel's Avatar
Wrox Staff
Points: 18,059, Level: 58
Points: 18,059, Level: 58 Points: 18,059, Level: 58 Points: 18,059, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
Default Excerpt article: Using Generic Methods

Another article is posted from Professional .Net 2.0 Generics by Tod Golding. Here's the intro:

Using Generic Methods

So much attention gets paid to the new generic classes that have been introduced with .NET generics, I often find developers overlooking what can be achieved through the use of generic methods. In fact, in many cases, you may discover one of the first opportunities to leverage generics is by introducing some generic methods into your non-generic types. This brings the flavor and power of generics to a class without requiring the class itself to be parameterized.

The Basics
To illustrate the fundamental value of generic methods, let's start with the simplest of examples. Suppose you have a Max() function that accepts two double values, compares them, and returns the greater of the two values. This function might appear as follows:

[VB code]
Public Function Max(ByVal val1 As Double, ByVal val2 As Double)
As Double
    Return IIf(val2 < val1, val1, val2)
End Function
[C# code]
public double Max(double val1, double val2) {
    return (val2 < val1) ? val1 : val2;
}

...

That's the beginning. You can read the rest of the article online here.

Jim Minatel
Senior Acquisitions Editor
Wiley Technology Publishing
WROX Press
Blog: http://wroxblog.typepad.com/
Jim's Book of the week: No book this week - Donate to the Red Cross!
__________________
Jim Minatel
Associate Publisher, WROX - A Wiley Brand
Did someone here help you? Click on their post!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Nice Article on Generic Paging jimibt BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 August 15th, 2007 10:49 AM
.NET 2.0 article: Understanding Generic Classes jminatel .NET Framework 2.0 1 May 4th, 2007 07:30 AM
Error in BLL.Article.Article.cs drohm BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 August 14th, 2006 09:56 AM
New excerpt article: Using Generic Methods jminatel C# 2005 0 May 5th, 2006 04:23 PM
Excerpt: Understanding Generic Classes jminatel C# 2005 0 April 11th, 2006 08:12 PM





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