1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anna007 [38]
2 years ago
10

Create a dictionary with types as integer and string.

Computers and Technology
1 answer:
Airida [17]2 years ago
7 0

Answer:

In c#  Dictionary is the collection of keys and value .The dictionary is a generic collection class which is in the System.Collection.Generics namespace. we can represent dictionary like that Dictionary<TKey, TValue> where TKey represent the type of key and TValue is the type of TValue.

Following are the example which represent dictionary as integer and string

using System.Collections.Generic;  // namespace

class Test // class test

{

   static void Main()  // main method

   {

       

       var ob = new Dictionary< int,string>();  // type integer and string

       dictionary.Add( 2,"hello");

       dictionary.Add(143,"hello1);

       // The dictionary has 2 pairs.

       Console.WriteLine("DICTIONARY 1 " + ob.Count);

}

}

Output:

DICTIONARY 1 :2

Explanation:

In this program we create a dictionary generic class which is integer and string type after that we add the elements in the dictionary by   "dictionary.Add method " and finally print the count of dictionary

You might be interested in
Number Array Class
UNO [17]

Answer:

Here is the Array class named Number:

#include <iostream>

#include <iomanip>

using namespace std;

class Number {

private:                            

   int size;                      

   float *ptr;                

   float num;                

   

public:                                          

   Number(){

       cout<<"Enter size of array: ";

        cin>>size;                            

   ptr = new float[size];  

   cout<<"Enter elements"<<endl;

   for(int i=0;i<size;i++)     {

       cin>>ptr[i];     }     }

   

   void getNumbers(){

        cout << "{ ";                    

   for (int i = 0; i < size; i++)           {

       cout <<ptr[i] <<setprecision(2)<< " ";             }

   cout << "}";            }

   

   Number(int s){

       ptr = new float[s];          

       size = s;      

   for (int i = 0; i < size; i++)     {

       cout << "Enter elements : ";    

       cin >> num;                          

       ptr[i] = num;         }  }

   

   ~Number(){

        delete [] ptr;    }

   void storeNumber(int input, float num){

        while (input < 0 || input > size-1)  {

       cout << "array size exceeded! Enter an element again " << endl;    

       cin >> input;    

       if (input >= 0 && input < size)  {

           ptr[input] = num;  

           break;       }   }

     if (input >= 0 && input < size)  {

       ptr[input] = num;   }  }

   

   void retrieveNumber(int position){

        while (position < 0 || position > size-1)  {

       cout << "array size exceeded! Enter an element again " << endl;    

       cin >> position;      

        if (position >= 0 && position < size)  {

           cout << "The number at "<<position<<"is: " << ptr[position];  

           break;           }     }      

   if (position >= 0 && position < size)     {

      cout << "The number at "<<position<<" is: " << ptr[position];     }   }    

 

   float HighestNumber(){

       float highest = ptr[0];      

   for (int i = 1; i < size; i++)     {

       if (ptr[i] > highest)         {

           highest = ptr[i];              }     }      

   return highest;      }

   

   float LowestNumber(){

       float lowest = ptr[0];      

   for (int i = 1; i < size; i++)     {

       if (ptr[i] < lowest)         {

           lowest = ptr[i];              }     }      

   return lowest;      }

   

   float AverageNumber(){

       float avg = 0.0;        

   for (int i = 0; i < size; i++)     {

       avg += ptr[i];         }      

   return avg/size;     }    

};

int main() {

   Number array;    

   array.getNumbers();    

   cout << endl;    

   int pos;        

   float no;    

   cout << "Choose an element to replace: ";  

   cin >> pos;    

   cout << "What number do you want to replace element with?" << endl;  

   cin >> no;    

   array.storeNumber(pos, no);

   array.getNumbers();  

   cout << endl;    

   int pos1;  

   cout << "Enter an element to retrieve the number: ";  

   cin >> pos1;    

   cout << endl;  

   array.retrieveNumber(pos1);  

   cout << endl;    

   cout << endl;    

   cout << "The highest number is: " << array.HighestNumber() << endl;    

   cout << "The lowest number is : " << array.LowestNumber() << endl;      

   cout << "Average of all numbers is : " << array.AverageNumber() << endl;    

    cout << endl;    

   return 0;        }

Explanation:

The program is well explained in the comments mentioned with each line of code in the attached document.

The screenshot of the program along with its output is attached.

4 0
3 years ago
What is one major difference between the roles of film directors and theater directors? A. A theater director is involved in sel
Umnica [9.8K]

Answer:

the answer is a cause I did this at my school and I learned about it so it A,

7 0
2 years ago
Consider the following code segment. for (int a = 0; a &lt; 10; a++) { for (int b = 10; b &gt; a; b--) { System.out.print("#");
Ket [755]

Answer:

55

Explanation:

Given the codes as below:

  1.        for (int a = 0; a < 10; a++)
  2.        {
  3.            for (int b = 10; b > a; b--)
  4.            {
  5.                System.out.print("#");
  6.            }
  7.        }

There are two layer loops in the code. The outer loop (Line 1) will run for 10 iterations by traversing through a = 0 to a=9. However, the inner loop  (Line 3) will run for 10 + 9 +  8 + 7 +...+ 1 = 55 iterations.

Since the print statement is within the inner loop (Line 5) and therefore the number of printed "#" symbols is dependent on the number of iterations of the inner loop. There will be 55 "#" symbols printed.

6 0
3 years ago
Good Morning! Please Help!
vova2212 [387]

Answer:

cyber bullying

rights

technology

speech

education

study

issues

Explanation:

4 0
3 years ago
Someone, please answer this.
Sav [38]

Answer: A loop will continue running until the defined condition returns false . ... You can type js for , js while or js do while to get more info on any of these. ... initialization - Run before the first execution on the loop. ... But it can be used to decrement a counter too. statement - Code to be repeated in the loop.

Explanation:

7 0
2 years ago
Other questions:
  • Rachel is on her way to an interview for the position of a project manager. She is trying to prepare for this interview by analy
    6·1 answer
  • The project started the development of inter-network connections using tcp/ip that has evolved into the internet today.
    5·1 answer
  • Who is president is US
    5·1 answer
  • Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the g
    7·2 answers
  • Analyst is investigating proxy logs and found out that one of the internal user visited website storing suspicious java scripts.
    8·1 answer
  • A 10-foot ladder must make an angle of 30° with the ground if it is to reach a certain window. What angle must a 20-foot ladder
    9·2 answers
  • What is output? Select all that apply.
    15·1 answer
  • Develop a Python program. Define a class in Python and use it to create an object and display its components. Define a Student c
    11·1 answer
  • 100 POINTS!!!!!!!!
    6·2 answers
  • JAVA -Develop a program that prompts the user to enter a series of 10 integers and then determines and displays the largest and
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!