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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:41:04+00:00 2026-06-03T03:41:04+00:00

I have a dictionary that takes in a tuple function and an int Dictionary<Tuple<string,string>,

  • 0

I have a dictionary that takes in a tuple function and an int

Dictionary<Tuple<string,string>, int> fullNames = new Dictionary<Tuple<string,string>, int>();

Where the Tuple class is defined as

public class Tuple<T, T2> 
{ 
    public Tuple(T first, T2 second) 
    { 
        First = first; 
        Second = second; 
    } 
    public T First { get; set; } 
    public T2 Second { get; set; } 

}

I want to use the Containskey function as such

if (fullNames.ContainsKey(Tuple<"firstname","lastname">))

But I am getting an overload error. Any suggestions?

  • 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-03T03:41:04+00:00Added an answer on June 3, 2026 at 3:41 am

    The code you have provided is invalid, since you’re trying to provide a type definition in the place where an actual object should be (and the type definition is invalid too, since a string is not actually the type System.String that a generic expects). If the tuple is the key value for the dictionary, then you can do this:

    if(fullNames.ContainsKey(new Tuple<string, string>("firstname", "lastname")))
    

    But then you can run afoul of the reference equality issue since two tuples created in memory with the same properties are not necesarily the same object. It would be better to do this:

    Tuple<string, string> testTuple = new Tuple<string, string>("firstname", "lastname");
    if(fullNames.Keys.Any(x => x.First == testTuple.First && x.Second == testTuple.Second))
    

    That will tell you if a key exists that shares the same property data. Then accessing that element is going to be just as complicated.

    EDIT: Long story short, if you plan on using a reference type for your key, you need to make sure your object implements Equals and GetHashCode in a way to properly identify two separate in memory instances are the same.

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

Sidebar

Related Questions

I have a WCF application, written in VB.NET that takes a generic Dictionary(Of String,
I have a Dictionary<string,int> that has the potential to contain upwards of 10+ million
I have a method that takes a List<int> , which is a list of
So we have this SYS_CONTEXT function in Oracle, which takes two parameters, first a
Currently, I have a class that is parsing XML and sending the dictionary that
I have an application that takes a dictionary of files (file type, and list
I have a class that takes standard address properties and stores them. The State
In Python, I have a Graph class that has a dictionary of vertex objects.
I have some code that takes an NSString as input and uses that string
I have code that takes as an argument a Dictionary and returns a Dictionary.

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.