posted 8/1/2011 by priti1desai - Views: [1000]
"Generic" --- means applicable to, or referring to all the members of a genus, class, group, or kind in English., but how about the meaning of the same word in a Programming language?Well so lets get going and learn something interesting :)To start with the basics, we all know in ASP.NET every variable and constant has a type, and there are main two types in .NET 1.Value Types &2.Reference TypesValue type variables directly contain their values, which means that the memory is allocated inline in whatever context the variable is declared. There is no separate heap allocation or garbage collection overhead for value-type variables. Eg: Integers,Boolean,structReference types store a reference to the value's memory address, and are allocated on the heap. Basically like a Pointer in C++ which points to the memoray location , however they dont really seem to contain the actual Data . Eg:Classes, Delegates,Array,InterfacesTaking above two into consideration .NET came up with Objects which can accepts both the Types ie Value & Reference Type .. which is now called Generics Collection Examples of Generic Collection are 1.Dictionary<TkeY ,Tvalue>2.List<T>3.Sorted Dictionary<> and few moreExamples of Non-Generic Objects are1.HashTable<Key,Value>2.Arrays and few more
More to be added soon