Skip to content

Differences between method overloading and Generics

Harsha N

Asked Apr 20, 2009, 9:47 AM EDT1 answer
Share
LinkedInX
Hi All,

   I am new to C#, would someone share their insight on "differences between method overloading and Generics" .can't one use method overloading instead of Generics.How is Generics understood by the C# compiler at run time.

Regards
Harsha

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0
    In method overloading process, you predefine method parameter types. When compile, your assembly already knows what types to expect in a method.

    Generics on the other hand does not have predefined types. You can pass any type in generics because they work based on object type.

    For execution purpose, method overloading is faster then generics.

    Both are two different things and you can't compare. Purpose is different. I suggest you search this site for generics to learn more about them.
    0