다음을 통해 공유


C# typedef

Has anyone else found themselves doing the following:

      public class FooList : System.Collections.Generic.List<Foo>

      {

      }

Rather than just using or exposing the List<Foo> type directly? For some reason I prefer the strongly type name. True, I would most likely expand on this class for such things as an overloaded Add() method, etc. Anyone see anything wrong with this? Will you end up with too many (trivial?) classes to maintain?

Comments

  • Anonymous
    July 06, 2004
    The comment has been removed

  • Anonymous
    July 06, 2004
    I don't think this is as necessary as it was in C++. Judging by your "typedef" headline I'd say your habits are also C++ heritage. However, in C++ I used to typedef in a way similar to above because there were inner types I needed (think iterators) and I did not want to type GenericType<SomePotentiallyVeryLongName>::iterator where GenericFoo::iterator sufficed. This does not seem to be practice with C# so I don't envision the need.

  • Anonymous
    July 07, 2004
    The comment has been removed

  • Anonymous
    July 26, 2004
    The thing is that in C++ as with C#, generic types are still strongly typed. And all of their methods are as well. So if you are worried about strong typing then you don't need to do what you are doing.

  • Anonymous
    July 26, 2004
    No, I'm not worried about compile time or runtime issues, this is merely a cosmetic thing.

  • Anonymous
    November 06, 2006
    I've just seen a blog entry about C# generics, concerning C#'s lack of typedef s. Actually, C# has a

  • Anonymous
    January 26, 2009
    I&#39;ve just seen a blog entry about C# generics, concerning C#&#39;s lack of typedef s. Actually, C#