Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is Generic? explain clearly?

Answer Posted / mithun

By using a generic class, we can create classes that is type safe at compile time.

ArrayList is a highly convenient collection class that can be used without modification to store any reference or value type. Any reference or value type that is added to an ArrayList is implicitly upcast to Object. If the items are value types, they must be boxed when they are added to the list, and unboxed when they are retrieved. Both the casting and the boxing and unboxing operations decrease performance

ArrayList list = new ArrayList();
list.Add(3);
list.Add("It is raining in Redmond.");
int t = 0;
foreach (int x in list)
{
t += x;
}

This will cause a programming error, and this error will not be detected until runtime.


In the generic List<T> collection, the same operation of adding items to the collection
List<int> list1 = new List<int>();
list1.Add(3);
list1.Add("It is raining in Redmond."); // this gives Compile-time error.

Now you can create a list that is not only safer than ArrayList, but also significantly faster, especially when the list items are value types.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is advantage of asp.net?

1033


What is boxing and unboxing in asp.net?

1117


What is the sequence in which ASP.NET events are processed?

1176


Explain About duration in caching technique

1114


How to include silver light .xap page into asp.net web application and what is the purpose of using silverlight application?

2771


Can you explain one critical mapping? Performance issue which one is better?

946


How do I open an ashx file in windows 7?

1114


What is asp.net localization?

1029


What is the difference between mvc (model-view-controller) and mvp (model-view-presenter)? : asp.net mvc

1068


If you are using two select queries and retrieving data. how do you access second query's result set using data reader?

5653


How can you handle errors in Web API?

1213


Define what is razor? : asp.net mvc

1050


What is a pixel url?

989


What is difference between mvc and asp.net? : Asp.Net MVC

1269


What is the difference between file-based dependency and key-based dependency?

1112