
Hashtable y método Item
Publicado por Nicolás (1 intervención) el 10/07/2022 21:41:39
Hola! ¿Cómo están?
Quería hacer una consulta, a ver si me pueden ayudar. Estoy intentando utilizar con Hashtable el método Item.
El namespace System.Collections lo estoy utilizando. El problema es que al usar el método .Item VisualStudio
me dice " 'Hashtable' no contiene una definición para 'Item' ni un método de extensión accesible 'Item' que acepte un primer argumento del tipo 'Hashtable'"-
¿Alguien tiene idea de cual puede ser el problema? Les envío mi código:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSHARP
{
internal class Program
{
static void Main(string[] args)
{
float valor;
Hashtable miTabla = new Hashtable();
miTabla.Add("Pan", 5.77);
miTabla.Add("Soda", 10.85);
miTabla.Add("Atún", 15.50);
valor = (float)miTabla.Item["Pan"];
Console.WriteLine("{0}", valor);
Console.ReadKey();
}
}
}
Quería hacer una consulta, a ver si me pueden ayudar. Estoy intentando utilizar con Hashtable el método Item.
El namespace System.Collections lo estoy utilizando. El problema es que al usar el método .Item VisualStudio
me dice " 'Hashtable' no contiene una definición para 'Item' ni un método de extensión accesible 'Item' que acepte un primer argumento del tipo 'Hashtable'"-
¿Alguien tiene idea de cual puede ser el problema? Les envío mi código:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSHARP
{
internal class Program
{
static void Main(string[] args)
{
float valor;
Hashtable miTabla = new Hashtable();
miTabla.Add("Pan", 5.77);
miTabla.Add("Soda", 10.85);
miTabla.Add("Atún", 15.50);
valor = (float)miTabla.Item["Pan"];
Console.WriteLine("{0}", valor);
Console.ReadKey();
}
}
}
Valora esta pregunta


0