• m_r_butts@kbin.social
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    edit-2
    10 months ago

    It can’t be actual C#, but it does look like it.

    If you declare a class Pie{} then attempt to call typeof(Pie) or typeof(T) it won’t even build because you failed to specify what type T is. typeof(Pie) would work but that just returns “Pie1[System.Object]”.

    • tonur@feddit.dk
      link
      fedilink
      English
      arrow-up
      5
      ·
      10 months ago

      I have used typeof(T) inside the generic class, so fx a function inside the class Pie where T can be refered. But out of context, if you were to call typeof(T) inside Program.cs’s main function, it would not work.

      • m_r_butts@kbin.social
        link
        fedilink
        arrow-up
        3
        ·
        10 months ago

        Yeah, but to do that you’d need an instantiated instance of the Pie class, which would answer in the context of the generic type parameter, not the whole Pie class.

        This is too funny. Everyone here, me included, is profoundly overthinking this, lol.

    • Kogasa@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      10 months ago

      I don’t get what you mean. You can define class Pie and instantiate it with the type argument Pie.

      Huh, maybe I don’t get it because Lemmy is literally erasing angle brackets from our messages. Not just “not rendering.” It’s removing them entirely. There should be four angle brackets in the first line of this comment…