5
When I keep the value of this Hastable
he makes me wrong.
Follows the code:
Hashtable ht = new Hashtable();
ht.Add("index", index);
ht.Add("tipo", "1");
string tipo = ht["tipo"];
5
When I keep the value of this Hastable
he makes me wrong.
Follows the code:
Hashtable ht = new Hashtable();
ht.Add("index", index);
ht.Add("tipo", "1");
string tipo = ht["tipo"];
6
When you re-turn a Hastable value you have to convert it to String like this:
string tipo = ht["tipo"].ToString();
6
First, do not use this data structure, it is considered obsolete and should no longer be used by any application. Prefer Dictionary<K, V>
. Once this is done the problem will not occur. If you insist you will have performance problems and errors of this type, which can even be solved (making conversion, for example), but not worth the effort.
var ht = new Dictionary<string, string> { ["index"] = "0", ["tipo"] = "1" };
string tipo = ht["tipo"];
Behold working in the ideone. And in the .NET Fiddle. Also put on the Github for future reference.
Browser other questions tagged c# .net string
You are not signed in. Login or sign up in order to post.
Thank you, but the exercise was imperative Hastable :)
– Myself
Thank you, but the exercise was imperative Hastable :)
– Myself
Jump out of the exercise. Thing that asks to do wrong thing will only bring you harm.
– Maniero