Well it turns out that I have a program where you ask the user to enter a barcode, name and price of a product then I keep these inside a Hashtable and in another class I have a method called ValidData and in this receipt as parameter the Hashtable, which I run with a foreach, the problem is that I need to get the value of an element within the foreach and verify that it does not exceed a certain number of characters but I do not know how to do it. this is a fraction of my code:
public void nuevo(){
c.WriteLine("Ingresar codigo de barras");
string code =c.ReadLine();
c.WriteLine("Ingresar nombre");
string nom =c.ReadLine();
c.WriteLine("Ingresar precio");
double pre =Double.Parse(c.ReadLine());
Hashtable valores = new Hashtable();
valores.Add("Codigo", code);
valores.Add("Nombre", nom);
valores.Add("Precio", pre);
prod.store(valores);
}
public class ProductController { public ProductController () { }
public void store(Hashtable valores){
ICollection keys = valores.Keys;
foreach(Object f in keys){
c.WriteLine(f + " = " + valores[f] );
if(f.Equals("Codigo")){
// Aqui necesito acceder al elemento con el key "Codigo"
// y mandar un mensaje de error en caso de que el valor ingresado sea
// mayor a 13
}else{
if(f.Equals("Nombre")){
}else{
if(f.Equals("Precio")){
}
}
}
}
}
}