Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. when i have to use and when i shld not use generics ?

when i have to use and when i shld not use generics ?

Scheduled Pinned Locked Moved C#
question
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    md_azy
    wrote on last edited by
    #1

    Hi, when i have to use and when i shld not use generics ? Thanks in advance Azeez.

    A P P L 4 Replies Last reply
    0
    • M md_azy

      Hi, when i have to use and when i shld not use generics ? Thanks in advance Azeez.

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Check this one. http://msdn.microsoft.com/en-us/library/ms172194.aspx[^] :)

      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


      My Latest Articles-->** Simplify Code Using NDepend
      Basics of Bing Search API using .NET
      Microsoft Bing MAP using Javascript

      1 Reply Last reply
      0
      • M md_azy

        Hi, when i have to use and when i shld not use generics ? Thanks in advance Azeez.

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        A quick rule of thumb - if your application is doing boxing/unboxing and there are common features on a class, possibly based off an interface, then you should really consider using generics.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        1 Reply Last reply
        0
        • M md_azy

          Hi, when i have to use and when i shld not use generics ? Thanks in advance Azeez.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          You never have to.

          1 Reply Last reply
          0
          • M md_azy

            Hi, when i have to use and when i shld not use generics ? Thanks in advance Azeez.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Wherever you can - Generics is a very broad subject and it has many applications. It allows your code to work with more than one type at runtime with type safety. If you use a generic List instead of an object array, there's no boxing/unboxing happening at runtime which actually improves performance by orders of magnitude. And there are millions of advantages. I would suggest that you go over the articles on the Internet to learn generics. Initially it may seems to be a complicated technology, but once you start appreciating its purpose, thing will be easy for you. Essential C# 2.0: Chapter 11: Generics[^]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups