Hi i am trying to make my own little config reader for my programs I got most of it working but i am haveing troble trying to return a list from a class, evey time i type the class name the list function does not show up in the list eveything else works fine, I left my class code here so maybe someone can see what i am doing wrong thanks.
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace TestConfig{ public class MyConfig { private string _Filename; private static Dictionary<string, string> Lines = new Dictionary<string, string>(); public MyConfig(string localname) { this._Filename = localname; string sLine; int cnt = 0; //Check if file is here if (!File.Exists(localname)) { throw new FileNotFoundException("File Not Found:\n" + this._Filename); } else { using (StreamReader sr = new StreamReader(this._Filename)) { while (!sr.EndOfStream) { sLine = sr.ReadLine().Trim(); //Check for comments if (sLine.StartsWith("//")) { cnt++; Lines.Add(cnt.ToString(), sLine); } else { //Get position of space int spos = sLine.IndexOf(" "); //Check for space position if (spos != -1) { //Extract key string sKey = sLine.Substring(0, spos).ToLower(); //Extract value string sValue = sLine.Substring(spos + 1, sLine.Length - spos - 1); //Add to the dir Lines.Add(sKey, sValue); } } } } } } public static List<string> Keys() { List<string> items = new List<string>(); items.AddRange(Lines.Keys); return items; } public string ReadValue(string keyname) { try { return Lines[keyname]; } catch { return ""; } } } }




Reply With Quote