Help on Dictionary copy

This is a discussion on Help on Dictionary copy within the C# Programming forums, part of the General Programming Boards category; Code: // create dictionaries public Dictionary<string, int> colors = new Dictionary<string, int>(); public string color; // name for dictionary public ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    20

    Help on Dictionary copy

    Code:
    // create dictionaries
        public Dictionary<string, int> colors = new Dictionary<string, int>();
        public string color; // name for dictionary
       
        public Dictionary<string, string> geneo = new Dictionary<string, string>();
        public string gtype; // name for dictionary
        
     // create unlinked dictionaries
            public Dictionary<string, string> geneo2 = new Dictionary<string, string>(); // Unlinked
            public string gtype2; // name for dictionary
            public Dictionary<string, int> colors2 = new Dictionary<string, int>(); // Unlinked
            public string color2; // name for dictionary
    This is where I run into problems
    Code:
    
                // copy dicitionaries
                Dictionary<string, int> colors copy = new Dictionary<string, int>(colors2);
    What is the correct syntax?

  2. #2
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    435
    Code:
    Dictionary<string, int> colorsCopy = new Dictionary<string, int>(colors2);
    Code:
    colors copy
    is not a valid identifier name.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dictionary
    By nshekofte in forum C# Programming
    Replies: 5
    Last Post: 07-28-2011, 04:40 PM
  2. foreach Dictionary
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-27-2008, 10:01 AM
  3. Dictionary Values copy
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-19-2008, 09:29 AM
  4. Dictionary reference
    By CodeMonkey in forum C++ Programming
    Replies: 4
    Last Post: 11-10-2003, 11:51 PM
  5. May I buy you a dictionary?
    By EvenFlow in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 10-19-2001, 12:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21