Can't create and initialize list (or hashtable) in one statement...?!

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

    Can't create and initialize list (or hashtable) in one statement...?!

    System.Collecti ons.Hashtable h = new System.Collecti ons.Hashtable() {
    null };

    Complains about ";" being expected after '()'.

    Using Visual Studio 2005. What's going on?
  • Ben Voigt [C++ MVP]

    #2
    Re: Can't create and initialize list (or hashtable) in one statement...?!

    Big Bird wrote:
    System.Collecti ons.Hashtable h = new System.Collecti ons.Hashtable() {
    null };
    >
    Complains about ";" being expected after '()'.
    >
    Using Visual Studio 2005. What's going on?
    for a list, you can do this:

    List<Tlist = new List<T>(new T[] { elem1, elem2, elem3, elem4 });


    Comment

    Working...