What is Generic? explain clearly?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / dhanunjaya
generic is a general data type in c# similar to template in
c++.by using generic we can assign any type of value to the
generic variable.we have generic methods,generic classes
also.
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / tejkrishna
Generics are the type like list<> collection but it can
contain any type within it like list<t>.
| Is This Answer Correct ? | 1 Yes | 1 No |
How does the XmlSerializer work? What ACL permissions does a process using it require?
How can we create a website?
Hi, I am developing an application (quiz engine) using C# in Dot net. My problem is I am designing the selction option using radio button. So, I want to retrive the data from the database to the radiobutton option. And also please tell me the how to compare the correct answer option with Answer selected by the users. If any body knows or have done this before please Help me out. My mail id is get_rome@yahoo.co.in. Table format: Question Id Queston Option1 Option 2 Option 3 Option 4 Correct answer 1 What is ur name? My name is ….. My name …. My name …. My name …. My name is tom
How would you create a permanent cookie?
What is asp.net with mvc? : Asp.Net MVC
What is ViewState ? and how it is managed ?
Contrast oop and soa. What are tenets of each16. How does the xmlserializer work? What acl permissions does a process using it require?
How to create a db connection at one place/page so that we can use that connection for all pages/forms/windows.what r the steps ned to be performed if question not clear,let me know
What are the different types of validation controls in asp.net?
what is client-server architecture in .net? and what is 3-tier architecture?
Explain the server control events of asp.net ?
Which template must you provide, in order to display data in a Repeater control?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)