what is the generics and where used generics in your project?

Answer Posted / jo

generics is similar to templates in c++ language
by using generics we can delay the type creation

for example we want to swap to values by using swap method
like here int swap(int a=10,int b=5)
{
int temp;
temp=a;
a=b;
b=temp;
}
here we declare the type of variable a first where it is
declared and also we swap to string
swap(string s1="hi",string s2="bye")
{
sting =temp;
temp=s1;
s1=s2;
s2=temp;
}
where we write two methods for two diferent types but using
generics we can achve this simply
swap(<t>a ="hi"<t>b,="bye")
{
<t> temp;
temp=s1;
a=b;
b=temp;
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the various types of cookies in asp.net?

753


Do you know using sql cache invalidation?

720


What are the session variables?

707


How can we prepairing Interview

2090


Give 2 examples for scenarios when routing is not applied?

789


What is routing in MVC?

796


In your ASP.NET 2.0 web application you want to display an image that is selected from a collection of images. What approach will you use to implementing this?

750


What is the difference between localization and globalization?

770


What is caching? Explain.

735


Explain the Order of events in an asp.net page?

784


what are configuration files?

737


What is HTTPModule and HTTPcontext? What is the use of each?

2209


Elaborate differentiation between Cache and Application?

721


What is the use of express session?

733


Which type if caching will be used if we want to cache the portion of a page instead of whole page?

687