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

Explain the different parts that constitute ASP.NET application?

563


How does asp page work?

540


What is work flow gen? how can it will work with .Net?

2574


In how many ways we can retrieve table records count?

532


What's the use of formatters in .net?

566






Explain asp.net web forms.

556


What is role-based security in asp.net?

519


What is the request flow used for asp.net mvc framework? : asp.net mvc

529


Name some asp objects?

542


Explain what the contents of cookie?

588


What is difference between singleton and single call?

642


How does session id work?

486


Explain Session state management options in ASP.NET.

586


What are Session states available and its Uses?

1691


Explain the code Access Security (CAS) in .net Framework?

664