I want to add Dictionary of about 200 strings in my game and want to compare input string given by user to the strings present in Dictionary i.e. whether input string has any meaning or not. Also i want to make sure that string in dictionary can be used only once i.e. repetition of strings is not allowed.
Please Please help me with this.
Thank You.
Just use HashSet<string>
probably the most efficient collection for this job. It provides uniqueness i.e. it won’t allow duplicate values. And whenever an input recieved you could check that with Contains() method.
//drag and drop a txt file into this variable
// separate your ideas on seperate lines
public TextAsset textfile;
public string[] arr;
string lookForMatch (string word){
string r = "no matches found";
int i = arr.Length;
while (i>0) {i--;
if(arr_!=""&&arr*.Contains(word)){*_
_ r = arr*;
arr=“”;break;}}
return r;*_
* }*
* void Start () {*
* // seperates the text file at lines*
* arr = textfile.text.Split ("
" [0]);*
* // will look for a word in you text file and give you the line only once*
* print ("I Found: "+lookForMatch (“bannana”));*
* }*
Just use HashSet<string>
probably the most efficient collection for this job. It provides uniqueness i.e. it won’t allow duplicate values. And whenever an input recieved you could check that with Contains() method.