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
Which method is used to enforce garbage collection in .net?
Tell me how asp.net mvc differs from asp.net web forms? : asp.net mvc
Define xmlreader class.
Explain culture and uiculture values.
What does uri mean?
What is Dynamic Web and discuss its usage with the help of real life examples?
Explain the procedure to handle the process request using mhpm events fired? : asp.net mvc
What is the difference between dispose() and finalize()?
How you can access the values from the Repeater control in ASP.NET?
Is it possible for me to change my aspx file extension to some other name?
What is mvc in asp.net tutorial? : Asp.Net MVC
What is strong-typing versus weak-typing?
What does the .webpart file do?
Why do we use web config?
Define session in asp.net.