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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:35:52+00:00 2026-06-14T06:35:52+00:00

I need to write a simple class. I need 2 methods: Vector property =

  • 0

I need to write a simple class.
I need 2 methods:

Vector property = new Vector();
property.add("key", "value"); //set value of key
property.get("key"); //return value of key

Does CSharp have a class like that?

I’m trying write my own class

string[] keys;

public void add(string key, string value)
{
 this.keys[key] = value;
}

but string can not be index of array(but must).

Any ideas?
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-06-14T06:35:54+00:00Added an answer on June 14, 2026 at 6:35 am

    You may use Dictionary<TKey,TValue> to do this. You may also define Vector as a class of Dictionary if you would like to use Vector as a Dictionary

    Example

    class Vector : Dictionary<string,string>
    {
        public string Get(string Key) //Create a new void Get(string Key) which returns a particular value from a specific Key in the Dictionary (Vector)
        {
            return this[Key]; //Return the key from the Dictionary
        }
        public void add(string Key, string Value) //Create a new void Add(string Key, string Value) which creates a particular value referring to a specific Key in the Dictionary (Vector)
        {
            this.Add(Key, Value); //Add the key and its value to Vector
        }
    }
    
    Vector property = new Vector(); //Initialize a new class Vector of name property
    property.add("key", "value"); //Sets a key of name "key" and its value "value" of type stirng
    MessageBox.Show(property.Get("key")); //Returns "value"
    //MessageBox.Show(property["key"]); //Returns "value"
    

    This will create a new class Vector which implements Dictionary so that you’ll be able to use Vector as a Dictionary.

    Notice: The Dictionary<TKey, TValue> is a generic class providing a mapping from a set of keys to a set of values. Each addition to the dictionary consists of a value and its associated key. Retrieving a value by using its key is very fast because the Dictionary<TKey, TValue> class is implemented as a hash table.

    Thanks,

    I hope you find this helpful 🙂

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

Sidebar

Related Questions

I need to write a simple program for work that does the following: read
As a part of our application I need to write simple workflow system which
I need to write a simple program that records all the input from parallel
I need to write a simple C# .NET application to retrieve, update, and insert
I need to write a simple source control system and wonder what algorithm I
I'm using Dev C++ to write a simple C program and I need to
I have a simple mod_rewrite question. What do I need to write in the
Sometimes when writing a class you'll need some helper methods that take care of
I want to write a vector class (or something other) on C++. And I
I need to write some methods for loading/saving some classes to and from a

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.