المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problem with String.Split()



C# Programming
06-24-2009, 10:24 PM
Hi i am new to OOP and c# , Im building a program that reads settings form a .cfg file .

I have managed to import the entrire cfg file into an array using string .split

onst string fName = @"Settings.cfg";
string[] lines = File.ReadAllLines(fName);
List fields = new List();
foreach (string s in lines)
{
if (s == "" || s.StartsWith(" ") || s.StartsWith("/"))
{
continue;
}
fields.AddRange(s.Split(new char[] { '=' }));
}
Settings = fields.ToArray();

However this also adds the setting name to the array which is not needed , is there any way to modify the code so only values to the right of the = get added to the array ?

Thanks