What is C#.NET Generics? where we can used in real time?

Posted by Bathala.ramesh430 under CSS 3 on 12/25/2010 | Points: 10 | Views : 77404 | Status : [Member] | Replies : 13
What is C#.NET Generics? where we can used in real time?

Thanks & Regards
Ramesh.B



Responses

Posted by: SheoNarayan on: 12/25/2010 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hello Bathala,

Generics allows us to define the type-safe classes without worrying about type safely, performance and performance.

A very good link to read about generics is http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx

However, you can visit http://www.dotnetfunda.com/interview/exam3644-what-is-csharpnet-generics.aspx and http://www.dotnetfunda.com/forums/thread804-generics.aspx as well.

Thanks!

Regards,
Sheo Narayan
http://www.dotnetfunda.com

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

Posted by: Karthikanbarasan on: 1/6/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Same questions is posted here as well

http://www.dotnetfunda.com/forums/thread1595-when-i-use-generics-in-a-dot-net-real-time-project.aspx

Thanks
Karthik
www.f5Debug.net

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

Posted by: Questpond on: 6/10/2011 [PanelMember] [Member] [Microsoft_MVP] [MVP] [Administrator] Starter | Points: 25

Up
0
Down
Generics helps you decouple data type from the logic , below video explains the same
http://youtu.be/7bKhAJpY9ho?hd=1

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

Posted by: Susanthampy on: 6/10/2011 [Member] [MVP] Bronze | Points: 25
Posted by: Susanthampy on: 6/10/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Also Try this,

http://www.dina.kvl.dk/~sestoft/gcsharp/

Regards,
Susan

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

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

Up
0
Down
Please try this link

http://www.dotnetperls.com/generic

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

Posted by: CGN007 on: 6/14/2012 [Member] Silver | Points: 25

Up
0
Down
http://www.c-sharpcorner.com/uploadfile/sdhar8po/genericsincsharp11152005055344am/genericsincsharp.aspx

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

Posted by: CGN007 on: 6/14/2012 [Member] Silver | Points: 25

Up
0
Down
http://www.akadia.com/services/dotnet_generics.html

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

Posted by: CGN007 on: 6/14/2012 [Member] Silver | Points: 25

Up
0
Down
Generics were added to version 2.0 of the C# language and the common language runtime (CLR). Generics introduce to the .NET Framework the concept of type parameters, which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code. For example, by using a generic type parameter T you can write a single class that other client code can use without incurring the cost or risk of runtime casts or boxing operations, as shown here:

C#


// Declare the generic class.

public class GenericList<T>
{
void Add(T input) { }
}
class TestGenericList
{
private class ExampleClass { }
static void Main()
{
// Declare a list of type int.
GenericList<int> list1 = new GenericList<int>();

// Declare a list of type string.
GenericList<string> list2 = new GenericList<string>();

// Declare a list of type ExampleClass.
GenericList<ExampleClass> list3 = new GenericList<ExampleClass>();
}
}


Source MSDNhttp://msdn.microsoft.com/en-us/library/512aeb7t%28v=vs.100%29.aspx

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

Posted by: CGN007 on: 6/14/2012 [Member] Silver | Points: 25

Up
0
Down
All about Generics in C#
http://beyondrelational.com/modules/2/blogs/61/posts/11217/all-about-generics-in-c.aspx

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

Posted by: Abhisekjani on: 6/20/2012 [Member] Starter | Points: 25

Up
0
Down
Hi ramesh.
go through the links this may helpful for you


http://msdn.microsoft.com/en-us/library/512aeb7t(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx

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

Posted by: CGN007 on: 6/23/2012 [Member] Silver | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

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

Posted by: Sravya on: 11/20/2012 [Member] Starter | Points: 25

Up
0
Down
Hi..

We can create a generic collection, that can handle any Type in a generic and Safe Manner.
example.In single Array class,we can use to store a list of users or list of products.
when we actually use it..we will be able to access the Items in the collection directly as a list of users or products...
(simply says...we needn't to do boxing/unboxing,casting when used Generics)

With Regards,
sravya

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

Login to post response