What is generic
What is generic in C#.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sivaraman DhamodaranRank #40 · 34.5K reputationPosted Oct 9, 2012, 3:22 AM EDT
AddNumbers(int a, int b);
AddNumbers(float a, float b);
AddNumbers(double a, double b);
We have three overloaded function that do Addition.
Now have a look AddNumbers(T a, T b);
Here T is called Generic Type.
And the function is called Generic Function as it can be called by AddNumbers(2,3) as well as AddNumbers(2.6, 7,4);
By using generic, you can avoid overloaded functions and multiple delcarations (Case A).
Satyapriya NayakRank #47 · 31.5K reputationPosted Oct 9, 2012, 3:38 AM EDT
Please refer the below links
http://msdn.microsoft.com/en-us/library/512aeb7t.aspx
http://www.c-sharpcorner.com/UploadFile/jgodel/Page102062006170216PM/Page1.aspx
http://www.csharp-station.com/Tutorial/CSharp/Lesson20
Thanks