I have a hashtable with A lot of words , when i introduce the words manually into the hashtable**[hashtable.add(id,“name”)]**it works perfectly with [hashtable.ContainsValue(InputField)], but somehow, when I introduce data in the hastable via automation, like
int i = 0;
foreach (string s in LinesDiccionaryD)
{
Tabla.Add(i, s.ToLower());
i++;
}
foreach (string s in LinesDiccionaryS)
{
Tabla.Add(i, s.ToLower());
i++;
}
it just stop working with [hashtable.ContainsValue(InputField)], how can i solve that, sorry for my english , and thx btw, I hope someone can help me
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
public class DiccionaryReader : MonoBehaviour
{
private string LastLine;
private string line;
public int currentLine = 0;
public int CurrentLine3;
public int CurrentLine4;
Hashtable Tabla;
private string[] lines;
private string[] LinesDiccionaryS;
public string[] LinesDiccionaryD;
private string content;
private string contentDiccionaryS;
private string contentDiccionaryD;
private string[] tokens;
public Text Palabra;
public Text Conjugacion;
public Text Tipo;
public Text Traduccion;
public bool SearchingForWord;
public bool UpdatingDiccionaries;
public bool UpdatingDiccionaryD;
public bool UpdatingDiccionaryS;
public InputField SearchWord;
public TextAsset file;
public TextAsset FileDiccionaryS;
public TextAsset FileDiccionaryD;
public void Start()
{
FileDiccionaryD = Resources.Load("Info/DiccionaryD") as TextAsset;
FileDiccionaryS = Resources.Load("Info/DiccionaryS") as TextAsset;
file = Resources.Load("Info/Diccionary") as TextAsset;
content = file.text;
contentDiccionaryD = FileDiccionaryD.text;
contentDiccionaryS = FileDiccionaryS.text;
lines = content.Split('
‘);
LinesDiccionaryD = contentDiccionaryD.Split(’
‘);
LinesDiccionaryS = contentDiccionaryS.Split(’
');
Tabla = new Hashtable();
NewWord();
int i = 0;
foreach (string s in LinesDiccionaryD)
{
Tabla.Add(i, s.ToLower());
i++;
}
foreach (string s in LinesDiccionaryS)
{
Tabla.Add(i, s.ToLower());
i++;
}
foreach (var key in Tabla.Keys)
{
Debug.LogWarningFormat("{0}: {1}", key, Tabla[key]);
}
}
public void NewWord()
{
{
var r = new System.Random();
int randomNumber = r.Next(0, lines.Length);
// Read the random line
line = lines.Skip(randomNumber - 1).Take(1).First();
string Output = line;
LastLine = line;
string MainString = Output;
tokens = MainString.Split('&');
Palabra.text = tokens[0];
Tipo.text = tokens[1];
Conjugacion.text = tokens[2];
Traduccion.text = tokens[3];
}
}
public void Update()
{
if (Tipo.text == "V")
{
Tipo.text = "Verbo";
}
else if (Tipo.text == "S")
{
Tipo.text = "Sustantivo";
}
else if (Tipo.text == "O")
{
Tipo.text = "Oracion";
}
else if (Tipo.text == "A")
{
Tipo.text = "Otro";
}
}
public void SearchForWord()
{
Debug.Log(Tabla.Count);
Debug.Log(SearchWord.text);
if (Tabla.ContainsValue("ab"))
{
Debug.Log("la encontre");
}
else if (Tabla.ContainsKey(SearchWord.text))
{
var key = Tabla[SearchWord.text];
Debug.Log(key);
}
else
{
Debug.Log("Ni Fruta idea que estas buscando");
}
}
}