[Microsoft Techies Blog] Using Generic Types class, method in console applica...

2 views
Skip to first unread message

Amit thakur

unread,
Aug 6, 2011, 12:19:48 AM8/6/11
to techie...@googlegroups.com
The .NET Framework provides generic versions for many of the collection classes that existed before version 2.0 of the .NET Framework. The generic collection classes are located in the System.Collections.Generic namespace.
A type definition that takes type parameters is called a generic type. You can define and use generic classes, structures, interfaces, methods, and delegates.

Defining a Generic Method:
A generic method is a method that specifies at least one type parameter. Client code can tailor the data types to its requirements each time that it calls the method. A method is not generic simply because it is defined inside a generic type. To be generic, the method must take at least one type parameter in addition to any normal parameters that it may take. A generic method can use its type parameters in its normal parameter list, in its return type if it has one, and in the method body.
To specify the type parameters for a generic method, append the (C#) notation after the method name. You can define multiple type parameters if necessary.

Following example display below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication10
{
class A
{
public T x;
public T1 y;

public void show(A x)


--
Posted By Amit thakur to Microsoft Techies Blog at 8/05/2011 09:19:00 PM
Reply all
Reply to author
Forward
0 new messages