none
Nested Dictionaries in C# RRS feed

  • Question

  • Hi, I'm migrating my VB-code to C# en i'm stuck with an elementary problem:

    Although VB-example works fine, C# Syntax is apparently not correct.

    What is wrong here?

    VB:

    private shared _Testdic as Dictionary(of string, string) From { "A", {"B", "C","D" }  };

    C#

    private static Dictionary<string, string[]> _Testdic = new Dictionary<string, string[]> { "A", {"B", "C","D" }  };

    Thanks to suggest a solution.


    • Edited by KSE60 Wednesday, March 29, 2017 12:24 PM
    Wednesday, March 29, 2017 10:16 AM

Answers

  • Found it myself, thx anyway

    private static Dictionary<string, string[]> _Testdic = new Dictionary<string, string[]>

    {

    {"A", new string[] { "A", "B", "C" }},

    {"1", new string[] { "2", "3", "4" }}

    };


    • Edited by KSE60 Wednesday, March 29, 2017 12:28 PM
    • Marked as answer by KSE60 Wednesday, March 29, 2017 12:29 PM
    Wednesday, March 29, 2017 12:28 PM