GENERICS IN DOT NET 3.5

Posted by Niranjan11 under Others on 7/31/2012 | Points: 10 | Views : 4466 | Status : [Member] | Replies : 8
Hi all


what are generics and how they are useful to us in programming especially in c# sharp


thanking you


cheers


have a nice day
Best Regards
niranjan yadav b

reagards
niranjan



Responses

Posted by: Oswaldlily on: 7/31/2012 [Member] Starter | Points: 25

Up
0
Down
http://www.c-sharpcorner.com/uploadfile/Ashush/generics-in-C-Sharp-part-i/

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajkatie on: 8/2/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
You can also refer video from following url
http://www.youtube.com/watch?v=7bKhAJpY9ho&list=PL54B7EC34478B0073&index=5&feature=plpp_video

Rajesh Patel
R.P.A Developer | Developer Trainer | Clean Code Evangelist

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Generic classes have type parameters. Several separate classes in a C# program, each with a different field type in them, can be replaced with a single generic class. The generic class introduces a type parameter. This becomes part of the class definition itself.

using System;

class Test<T>
{
T _value;

public Test(T t)
{
// The field has the same type as the parameter.
this._value = t;
}

public void Write()
{
Console.WriteLine(this._value);
}
}

class Program
{
static void Main()
{
// Use the generic type Test with an int type parameter.
Test<int> test1 = new Test<int>(5);
// Call the Write method.
test1.Write();

// Use the generic type Test with a string type parameter.
Test<string> test2 = new Test<string>("cat");
test2.Write();
}
}

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/14/2012 [Member] Bronze | Points: 25

Up
0
Down
Please Mark as Answer if it helpful to you..That helps others who search the same...

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
Good Explanation Muhsinathk

Thanks & Regards
Hari

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
Good Explanation CGN007


Thanks & Regards
Hari

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 9/17/2012 [Member] Bronze | Points: 25

Up
0
Down
Thanks Mr.Hari

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
welcome Muhsinathk

Thanks & Regards
Hari

Niranjan11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response