I am writing an application using C # and I would like to read some parameters from an external file, such as a text file, for example. The parameters will be saved in the file as
parA = 5 parB = hello etc
Can you ask how I can do this?
I know that this is not what you specifically asked, but if you have a choice, I would go with the configuration of the XML application.
It has a lot of resources, but here is a pretty simple example:
http://www.c-sharpcorner.com/UploadFile/dolson/XMLConfigInWinForms11262005014845AM/XMLConfigInWinForms.aspx
var settings = from line in File.ReadAllLines("params.txt") let parameters = line.Split('=') select new KeyValuePair<string, string>(parameters[0], parameters[1]);
Read each line and divide it by the first occurrence "=".
"="