Friday, August 5, 2011

Using Generic Types class, method in console application.

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)

No comments:

Recent Posts