• Top Posts

    What is a Generic Class in C# ?


    • Generics or Generic class is used to create classes or objects which do not have any specific data type. The data type can be assigned during runtime, i.e when it is used in the program.
    • So, from the code, we see 2 compare methods initially, to compare string and int.
    • In case of other data type parameter comparisons, instead of creating many overloaded methods, we can create a generic class and pass a substitute data type, i.e T. So, T acts as a datatype until it is used specifically in the Main() method.

    No comments

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728