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 8928255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:23:45+00:00 2026-06-15T08:23:45+00:00

I have one class, class AClass . In this class I’m filling two dictionaries

  • 0

I have one class, class AClass. In this class I’m filling two dictionaries and also, I’m returning these two dictionaries so I’ve used Tuple<Dictionary<string, string>, Dictionary<string, string>> type of method declaration:

class AClass
{
    Dictionary<string, string> dictOne = new Dictionary<string, string>();
    Dictionary<string, string> dictTwo = new Dictionary<string, string>();

    public Tuple<Dictionary<string, string>, Dictionary<string, string>> MyMethodOne()
    {
        //Adding items dictOne and dictTwo

        return new Tuple<Dictionary<string, string>, Dictionary<string, string>>(dictOne, dictTwo);
    }
}

In other class, class BClass, I should get these two dictionaries, access them and add their items to another two dictionaries:

 class BClass
 {
    AClass _ac = new AClass();

    Dictionary<string, string> dictThree = new Dictionary<string, string>();
    Dictionary<string, string> dictFour = new Dictionary<string, string>();

    public void MyMethodTwo()
    {
    //Here I should get dictionaries through Tuple
    //Add items from dictOne to dictThree
    //Add items from dictTwo to dictFour
    //In a way
    //   foreach (var v in accessedDict)
    //   {
    //   dictThree.Add(v.Key, v.Value);
    //   }
    }
}

If MyMethodOne was returning only one dictionary I would know how to get items from one dictionary to another but here I have Tuple, with which I have never worked, and I don’t know how how to get these two retuning values. Should I do it like this at all? Is there another way, maybe to declare method as Dictionary< Dictionary<string, string>, Dictionary<string, string>>?

So, how to get dictionaries from Tuple?

  • 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-15T08:23:45+00:00Added an answer on June 15, 2026 at 8:23 am

    The Tuple class exposes its members in properties called “Item(Number)”: http://msdn.microsoft.com/en-us/library/dd289533.aspx

    So, your two-items Tuple will have properties called Item1 and Item2:

    var dictionaries = _ac.MyMethodOne();
    // now dictionaries.Item1 = dictOne, dictionaries,Item2 = dictTwo
    dictThree = dictionaries.Item1;
    

    I don’t understand when you say that you want to “assign items” if you just want to get a reference to the dictionary or make a copy of it. If you want to make a copy, use

    dictFour = new Dictionary<string, string>(dictionaries.Item2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that contains a boolean field like this one: public class
I'm a Java-beginner, so please bear with this one. I have a class: class
I have two files: logic.scala and main.scala logic.scala contains one class and main.scala have
So suppose I have a class like this one: class Point { private: int
Somewhere in my code I have: class aclass { ... function amethod() { $this->dom
I have a problem.... Lest say I have a class like this one: public
I have a class expecting a two parameters template, like this: template<template <class, class>
I'm creating a class that will have one public method, which returns a value
I have a class A with a LinkedBlockingQueue as property. In one method of
I have a class A and write a subclass B. A has only one

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.