C# Generics.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eddie

    C# Generics.

    Hi,

    I've recently read the articles on generics in the .net
    framework (the next version) and just wanted to check a
    few points..

    As I understand, generic class instances while being
    strongly typed checked at compile time, are only created
    at runtime?? Is this correct??

    Secondly, can you inherit from a typed generic class??
    i.e.
    public class MySortedList:Ge nericSortedList <int32>
    {
    }

    ANy feedback would be sweet..

    thanks..

    Eddie
  • Ron McNulty

    #2
    Re: C# Generics.

    Hi Eddie

    This is from memory of a session at an MS conference, so it might not be
    100% correct.

    Generics will be type checked at compile time, and a class created for each
    class type and value type that uses them. For instance, if you have multiple
    lists containing ints, the internally only one set of code will be required
    to handle the lot. The generics in Rotor do not do this.

    I'm not sure that the issue of inheritance was discussed. I just assumed you
    can inherit. Take a look at the Rotor generics - they should tell you.

    Regards

    Ron

    "Eddie" <not@important. com> wrote in message
    news:07ab01c391 db$abbfb980$a40 1280a@phx.gbl.. .[color=blue]
    > Hi,
    >
    > I've recently read the articles on generics in the .net
    > framework (the next version) and just wanted to check a
    > few points..
    >
    > As I understand, generic class instances while being
    > strongly typed checked at compile time, are only created
    > at runtime?? Is this correct??
    >
    > Secondly, can you inherit from a typed generic class??
    > i.e.
    > public class MySortedList:Ge nericSortedList <int32>
    > {
    > }
    >
    > ANy feedback would be sweet..
    >
    > thanks..
    >
    > Eddie[/color]


    Comment

    • John Montgomery [MSFT]

      #3
      Re: C# Generics.

      We're planning to introduce generics starting with Visual Studio "Whidbey,"
      which we won't be talking a lot about until the Professional Developers
      Conference at the end of this month. If you want more information, check on
      MSDN the week of October 28th.

      Thanks,
      John

      Director, Product Management
      ..NET Framework
      Microsoft


      Comment

      • Eric Gunnerson [MS]

        #4
        Re: C# Generics.



        --
        Eric Gunnerson

        Visit the C# product team at http://www.csharp.net
        Eric's blog is at http://blogs.gotdotnet.com/ericgu/

        This posting is provided "AS IS" with no warranties, and confers no rights.
        "Eddie" <not@important. com> wrote in message
        news:07ab01c391 db$abbfb980$a40 1280a@phx.gbl.. .[color=blue]
        > Hi,
        >
        > I've recently read the articles on generics in the .net
        > framework (the next version) and just wanted to check a
        > few points..
        >
        > As I understand, generic class instances while being
        > strongly typed checked at compile time, are only created
        > at runtime?? Is this correct??[/color]

        The IL to implement a specific use of a generic class (ie List<int>) is
        created at JIT time, unless it's already been created. Each value type needs
        a separate set of IL, but reference types can share their IL.
        [color=blue]
        > Secondly, can you inherit from a typed generic class??
        > i.e.
        > public class MySortedList:Ge nericSortedList <int32>
        > {
        > }[/color]

        Yes.


        Comment

        Working...