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

  • Home
  • SEARCH
  • 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 300801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:56:51+00:00 2026-05-12T06:56:51+00:00

In the following code, the Type of our Dictionary is <int, Customer> , but

  • 0

In the following code, the Type of our Dictionary is <int, Customer>, but how do I know what’s the type of Customer? It seems like Customer is a string here since we’re Customer cust1 = new Customer(1, “Cust 1”); …. im confused…

 public class Customer
    {
        public Customer(int id, string name)
        {
            ID = id;
            Name = name;
        }

    private int m_id;

    public int ID
    {
        get { return m_id; }
        set { m_id = value; }
    }

    private string m_name;

    public string Name
    {
        get { return m_name; }
        set { m_name = value; }
    }
}

 Dictionary<int, Customer> customers = new Dictionary<int, Customer>();

Customer cust1 = new Customer(1, "Cust 1");
Customer cust2 = new Customer(2, "Cust 2");
Customer cust3 = new Customer(3, "Cust 3");

customers.Add(cust1.ID, cust1);
customers.Add(cust2.ID, cust2);
customers.Add(cust3.ID, cust3);

foreach (KeyValuePair<int, Customer> custKeyVal in customers)
{
    Console.WriteLine(
        "Customer ID: {0}, Name: {1}",
        custKeyVal.Key,
        custKeyVal.Value.Name);
}
  • 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-05-12T06:56:51+00:00Added an answer on May 12, 2026 at 6:56 am

    A Customer object is type Customer even though it consists of an int and a string. When you are calling Customer cust1 = new Customer(1, "Cust 1"); that is really saying “make me an object of type Customer which consists of the integer 1 and string Cust 1″

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

Sidebar

Related Questions

The following code throws an compile-time error like Cannot convert type 'string' to 'int'
I have the following code: Type type = typeof(T); foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Public
Lets say I've got the following code type IsTall = Bool type IsAlive =
I have following Delphi code: type RegbusReq2=packed record Funct:char; Device:char; Device1:char; Starting:integer; Quantity:smallint; _CRC:Word;
I am successfully instantiating/automating Visual Studio using the following code: System.Type t = System.Type.GetTypeFromProgID(VisualStudio.DTE.9.0);
the following code specifies a type MyBase64Binary which is derived from a base class
I have the following code: function callIframe(type, cat) { var send = false; var
Doing an ajax get request works as expected using the following code: $.ajax({ type:
The following code fails in 'Evaluate' with: This expression was expected to have type
The following code yields an error error: ‘struct Foo’ is not a valid type

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.