Hi friends
can anybody Explain Advantages and disadvantages of using generics.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Apr 7, 2012, 3:16 AM
Advantages of Generics:
More info:
http://msdn.microsoft.com/en-us/library/ms172194(v=vs.85).aspx
http://venkatcsharpinterview.blogspot.in/2011/05/advantages-and-disadvantages-of-using.html
VulpesPosted Apr 6, 2012, 6:02 AM
Jignesh TrivediPosted Apr 6, 2012, 12:57 AM
Generics are a new feature in 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.
A primary reason is the type safety at compile time. If you are passing two Type objects you are placing the responsibility at the developer instead of the compiler.
Another reason to use a generic is if you want to apply constraints to the type
Please refer,
http://msdn.microsoft.com/en-us/library/ms172194.aspx
MuthuMari MPosted Apr 6, 2012, 12:53 AM
Generics ,
Generic helps us to maximize the reuse of code, Type safety and better performance. Generics are most commonly used to create a collection. There are many new generic collection classes in the System.collection.Generics namespace. These classes are advised to be used for type safety and better performance over araylist.
We can also create our own Generic interface, classes, methods, events and delegates. Information on the types used in a generic data type may be obtained at run-time by means of reflection
Generics are a great way of writing classes that combine reusability, type safety and efficiency. Generics are commonly used with collections. .NET 2.0 has introduced a new namespace called System.Collections.Generic which contains classes that support generics.
The most common use for generic classes is with the collections like linked lists, hash tables, stacks, queues, trees and so on where operations such as adding and removing items from the collection are performed in more or less the same way regardless of the type of the data being stored.
Thanks.