- Home /
Value will not return from ArrayList, C#
I currently have an file parser with a Get method:
public string Get(string key){
Debug.Log("key="+key);
for(int i = 0; i < keys.Count; i++){
Debug.Log(keys[i]+":"+vals[i]);
if(keys[i] == key){
return vals[i].ToString();
}
}
return "";
}
Being called from another script:
public enum GraphicSettingType{
resolutionW,
resolutionH,
windowed,
quality
}
public class GraphicsSettings {
iniParser parser = new iniParser();
public void Create(){
parser.Set(GraphicSettingType.resolutionH.ToString(),Screen.currentResolution.height.ToString());
parser.Set(GraphicSettingType.resolutionW.ToString(),Screen.currentResolution.width.ToString());
parser.Set(GraphicSettingType.windowed.ToString(),Screen.fullScreen.ToString());
parser.Set(GraphicSettingType.quality.ToString(),"1");
parser.save(IniFiles.GRAPHICS);
}
public void load(){
parser.load(IniFiles.GRAPHICS);
Debug.Log("returned: "+parser.Get("resolutionW"));
//int sW = 0; //int.Parse(parser.Get(GraphicSettingType.resolutionW.ToString()));
//int sH = int.Parse(parser.Get(GraphicSettingType.resolutionH.ToString()));
//bool iW = bool.Parse(parser.Get(GraphicSettingType.windowed.ToString()));
//Debug.Log(sW+":"+sH+":"+iW);
//Screen.SetResolution(sW,sH,iW);
}
But it will not return a value, even though the name should be match on the loop.
untitled.png
(19.1 kB)
Comment
Best Answer
Answer by KellyThomas · Jan 12, 2014 at 03:28 AM
What type is keys[i]
going to return?
Depending on how keys
is declared you may need to use "`keys[i].Equals(key)`" as your equality test.