Salut.
D'abord, tu crées un fichier de config ("Add > New Item > Application Configuration File"). Ensuite, dans ton projet, tu ajoutes une référence à System.Configuration.
Après, voici un petit exemple de fichier de config "app.config" :
1 2 3 4 5 6
| <?xml version="1.0"?>
<configuration>
<appSettings>
<add key="myKey" value="myKeyValue"/>
</appSettings>
</configuration> |
Pour accéder à une valeur du bloc appSettings :
1 2 3
| using System.Configuration;
// ...
string myKeyValue = ConfigurationManager.AppSettings["myKey"]; |
Voilà, il existe également d'autres sections prédéfinies comme connectionStrings, mais tu peux en définir de nouvelles, etc., etc..
Bon courage 
Edit : Pour récupérer une section créée à la main :
1 2 3 4 5 6
| <?xml version="1.0"?>
<configuration>
<mySection>
...
</mySection>
</configuration> |
object mySection= ConfigurationManager.GetSection("mySection");
Partager