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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:59:05+00:00 2026-05-23T06:59:05+00:00

Suppose I have an array of strings like : myArray[hello, my, name, is, marco]

  • 0

Suppose I have an array of strings like :

myArray["hello", "my", "name", "is", "marco"]

to access to this variable, I have to put an integer as index. So if I wanto to extract the third element I just do :

myArray[2]

Now, I’d like to use label instead of integer.
So for example somethings like :

myArray["canada"]="hello";
myArray["america"]="my";
myArray["brazil"]="name";
myArray["gosaldo"]="is";
myArray["italy"]="marco";

How can I do this on C#? Is it possible? Thanks

  • 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-23T06:59:05+00:00Added an answer on May 23, 2026 at 6:59 am

    That’s called an associative array, and C# doesn’t support them directly. However, you can achieve exactly the same the effect with a Dictionary<TKey, TValue>. You can add values with the Add method (which will throw an exception if you try to add an already existing key), or with the indexer directly, as below (this will overwrite the existing value if you use the same key twice).

    Dictionary<string, string> dict = new Dictionary<string, string>();
    
    dict["canada"] = "hello";
    dict["america"] = "my";
    dict["brazil"] = "name";
    dict["gosaldo"] = "is";
    dict["italy"] = "marco";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a string of 123456789 . I would like to split this
Suppose i have input array byte A[50]; i have put three diffrent data types
Suppose I have a regex like this: @\b(one|two|three)\b; How can I get all of
Suppose you have output like this: Word1 Word2 Word3 Word4 Where the number of
suppose you have an array with a number of strings in ActionScript3 and you
Suppose I have a combobox where items are binded to an array of strings.
suppose there is a string like this string temp2 = hello; char[] m =
Suppose I have an array of string like following: str_arr=[10$, 10$ I am a
Suppose I have something like this int strLen; printf(Please enter a number: ); scanf(%d,
Suppose I have an array of a objects of user defined class. Wanted to

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.