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

How do we assign page-specific attributes?

706


What is the use of worker process in asp.net?

610


How can we create pie chart in asp.net?

679


How can we inherit a static variable?

620


Explain the difference between overriding and overloading?

623






What is session mode in asp.net?

604


What is the difference between Classic ASP and ASP.Net?

628


What is the use of data set in asp.net?

568


Explain global assembly cache.

669


What is the use of dispose method?

642


How do you change the session time-out value?

665


List some of the important session state modes of asp.net.

606


What is the use of global.asax file?

641


What is .net framework and what are the main components of it?

468


Explain the concept of View Model in MVC?

679