100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

subtema en el lenguaje c#

Rating
-
Sold
-
Pages
3
Uploaded on
12-08-2022
Written in
2022/2023

descripcion y enfoque de tablas hash

Institution
Course








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Study
Course

Document information

Uploaded on
August 12, 2022
Number of pages
3
Written in
2022/2023
Type
Class notes
Professor(s)
Isc
Contains
All classes

Subjects

Content preview

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// Crear una tabla hash utilizando la clase Hashtable disponible en
Collections

Hashtable thash1 = new Hashtable();/*La tabla se llama thashl, pero puede ser
cualquier nombre*/

// Agregando elementos a la tabla hash
//los valores pueden duplicarse pero no las claves
thash1.Add("txt", "Programa notepad.exe");
thash1.Add("bmp", "Pnograma paint.exe");
thash1.Add("dib", "Pnograna paint.exe");
thash1.Add("rtf", "Pnograma wordpad.exe");

//Comprobación de validación de que no se admiten llaves duplicadas

try{
thash1.Add("txt", "Programa winword.exe") ;

}catch{

Console.WriteLine("Un elemento con la clave = \"txt\" Ya existe \n");
}

//podemos obtener el valor utilizando la clave
Console.WriteLine("--------------------");
Console.WriteLine("Imprimimos un valor de la tabla usando la clave");
Console.WriteLine("Para la Clave = \"rtf\", valor = {0} ", thash1["rtf"] + "\n");

//También podemos cambiar el valor utilizando la clave thash1[”rtf”] =
"recortes.exe";
Console.WriteLine("------------------------");
Console.WriteLine("Cambiando valor asociado a clave rtf");
Console.WriteLine("Para la clave= \"rtf\", valor = {0}.", thash1["rtf"]);
Console.WriteLine("\n-------------------");

//si la clave no existe, al utilizar esta sintaxis también se puede agregar igual
que add
thash1["doc"] = "winword.exe";

// Comai nsKey puede ser usada para probar
// si una clave ya eXiste

if (!thash1.ContainsKey("ht"))
{
thash1.Add("ht", "hypertrm.exe");
Console.WriteLine("Valor Agregado para =\"ht\": {0}", thash1["ht"]);
$6.49
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
natanielestrada

Get to know the seller

Seller avatar
natanielestrada universidad autonoma de mexico
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
3 year
Number of followers
0
Documents
6
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions