Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9232385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:18:08+00:00 2026-06-18T06:18:08+00:00

Dictionary<string, List<Piese>> SetPiese = new Dictionary<string, List<Piese>>(); char[] litere = ABCDEFGHIJLMNOPRSTUVXZ.ToCharArray(); for (int i

  • 0
        Dictionary<string, List<Piese>> SetPiese = new Dictionary<string, List<Piese>>();

        char[] litere = "ABCDEFGHIJLMNOPRSTUVXZ".ToCharArray();

        for (int i = 1; i <= litere.Length; i++) {
            SetPiese.Add(litere[i], Set + litere[i]);
        }

        List<Piese> SetA = GenerareSetLitere("A", 1, 11);
        List<Piese> SetB = GenerareSetLitere("B", 9, 2);
        List<Piese> SetC = GenerareSetLitere("C", 1, 5);
        ................................................

So I have many lists and I want to add them to a dictionary. How can I do this right ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:18:09+00:00Added an answer on June 18, 2026 at 6:18 am

    Quite simply, don’t declare them in separate variables to start with. That will always be a pain to work with programmatically. If you’d started with:

    List<Piese>[] sets = new List<Piese>[]
    {
        GenerareSetLitere("A", 1, 11),
        GenerareSetLitere("B", 9, 2),
        GenerareSetLitere("C", 1, 5)
        ...
    };
    

    then you could use:

    // Note loop condition change
    for (int i = 0; i < litere.Length; i++) {
        SetPiese.Add(litere[i], sets[i]);
    }
    

    Or even better, if literere is actually a bunch of expressions you can specify inline, you could do the whole thing in a collection initializer:

    Dictionary<string, List<Piese>> SetPiese = new Dictionary<string, List<Piese>>
    {
        { "first-key", GenerareSetLitere("A", 1, 11) },
        { "second-key", GenerareSetLitere("B", 9, 2) }
    };
    

    etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Dictionary of dictionaries : SortedDictionary<int,SortedDictionary<string,List<string>>> I would like to merge two
Dictionary<string,List<string>> dict =new Dictionary<string,List<string>>(){...}; I need a result of dictionary type that filtered by
There is Dictionary<string,List<string>> dictionary=new Dictionary<string,List<string>>(); and var c; var c returns me values :
I have a List of String like List<String> MyList=new List<String>{A,B}; and a Dictionary<String, Dictionary<String,String>>
i've a Dictionary like Dictionary<String,List<String>> MyDict=new Dictionary<String,List<String>>(); and which contains { One { A,
How to convert Dictioanry<String,List<String>> into Dictionary<String,String> i'm having a dictionary like Dictioanry<String,List<String>>dictOne=new Dictionary<String,List<String>>(); and
I have created dictionary object Dictionary<string, List<string>> dictionary = new Dictionary<string,List<string>>(); I want to
What is the cost of len() function for Python built-ins? (list/tuple/string/dictionary)
I would like to convert a Dictionary to a string array (or list) The
In a Dictionary, How to convert a string into a list? Let x =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.