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. About generics [solved]

About generics [solved]

Scheduled Pinned Locked Moved C#
question
14 Posts 8 Posters 1 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.
  • E Offline
    E Offline
    E del Ayre
    wrote on last edited by
    #1

    ok, now i can see that this is possible; class Animals: IEnumerable {}; forget about the IEnumerable, im just trying to show some generic type of itself... im just bothered... where can we make use of this (a generic type of itself) in the real world?

    P M L J 4 Replies Last reply
    0
    • E E del Ayre

      ok, now i can see that this is possible; class Animals: IEnumerable {}; forget about the IEnumerable, im just trying to show some generic type of itself... im just bothered... where can we make use of this (a generic type of itself) in the real world?

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

      Belgium.

      L E K 3 Replies Last reply
      0
      • P PIEBALDconsult

        Belgium.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Yep, even our animals are smart enough to enumerate themselves. :laugh:

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        1 Reply Last reply
        0
        • P PIEBALDconsult

          Belgium.

          E Offline
          E Offline
          E del Ayre
          wrote on last edited by
          #4

          :laugh: hahah... good one, but that didnt help... think fast, be brave and dont stop.

          P 1 Reply Last reply
          0
          • E E del Ayre

            :laugh: hahah... good one, but that didnt help... think fast, be brave and dont stop.

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

            I'll have to think about it. Gimme 7.5 million years...

            X 1 Reply Last reply
            0
            • P PIEBALDconsult

              I'll have to think about it. Gimme 7.5 million years...

              X Offline
              X Offline
              Xmen Real
              wrote on last edited by
              #6

              Thank god, Apple didn't fall on you ;P

              TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>

              ----------------------------------------------- 128 bit encrypted signature, crack if you can

              1 Reply Last reply
              0
              • E E del Ayre

                ok, now i can see that this is possible; class Animals: IEnumerable {}; forget about the IEnumerable, im just trying to show some generic type of itself... im just bothered... where can we make use of this (a generic type of itself) in the real world?

                M Offline
                M Offline
                Mirko1980
                wrote on last edited by
                #7

                One i can think is a tree or a graph, where each node is defined as the collection of all its children.

                E 1 Reply Last reply
                0
                • M Mirko1980

                  One i can think is a tree or a graph, where each node is defined as the collection of all its children.

                  E Offline
                  E Offline
                  E del Ayre
                  wrote on last edited by
                  #8

                  yeah, i thought of the same with nodes... but the thing is, on an engineering standpoint we already have better implimentations of a node... wont a collection as a node just bloat everything? :sigh: newez, was just hoping for something 'unique' that it can solve with... or maybe im just crossing the line where it says 'bad design on generics' here... :(

                  E 1 Reply Last reply
                  0
                  • E E del Ayre

                    ok, now i can see that this is possible; class Animals: IEnumerable {}; forget about the IEnumerable, im just trying to show some generic type of itself... im just bothered... where can we make use of this (a generic type of itself) in the real world?

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

                    Does class A : IComparable<A> { } count?

                    E 1 Reply Last reply
                    0
                    • E E del Ayre

                      yeah, i thought of the same with nodes... but the thing is, on an engineering standpoint we already have better implimentations of a node... wont a collection as a node just bloat everything? :sigh: newez, was just hoping for something 'unique' that it can solve with... or maybe im just crossing the line where it says 'bad design on generics' here... :(

                      E Offline
                      E Offline
                      E del Ayre
                      wrote on last edited by
                      #10

                      what im really fussing about is that this can be more than just on collections... its generic interfaces, objects, and what nots on itself... u know... :wtf: think fast, be brave and dont stop.

                      1 Reply Last reply
                      0
                      • L Lost User

                        Does class A : IComparable<A> { } count?

                        E Offline
                        E Offline
                        E del Ayre
                        wrote on last edited by
                        #11

                        rights... now i feel stupid... hehehe... got my 5 here... thanks... think fast, be brave and dont stop.

                        1 Reply Last reply
                        0
                        • E E del Ayre

                          ok, now i can see that this is possible; class Animals: IEnumerable {}; forget about the IEnumerable, im just trying to show some generic type of itself... im just bothered... where can we make use of this (a generic type of itself) in the real world?

                          J Offline
                          J Offline
                          J4amieC
                          wrote on last edited by
                          #12

                          How about a factory

                          public class GenericFactory<T> where T : new()
                          {
                          public T Create(){
                          return new T();
                          }
                          }

                          E 1 Reply Last reply
                          0
                          • J J4amieC

                            How about a factory

                            public class GenericFactory<T> where T : new()
                            {
                            public T Create(){
                            return new T();
                            }
                            }

                            E Offline
                            E Offline
                            E del Ayre
                            wrote on last edited by
                            #13

                            no, the guy up there got it... i wanted to see the declared type (itself) being passed back into the generic... (with some sense into it) think fast, be brave and dont stop.

                            1 Reply Last reply
                            0
                            • P PIEBALDconsult

                              Belgium.

                              K Offline
                              K Offline
                              Keith Barrow
                              wrote on last edited by
                              #14

                              What a beautiful answer: Totally useless, sarcastic and technically correct in all respects at the same time. I want to 5 you, but I know I shouldn't :-).

                              Sort of a cross between Lawrence of Arabia and Dilbert.[^]

                              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