Как заявить публично во всех заявках?
Hello, I do not know how to declare a public variable, for example I would like to declare the search for a file and keep for all my application the same value. Here is my code below, how to always have the name (DBpath). Thank you in advance.
Что я уже пробовал:
<pre> // search the disks if the folder exists string[] drives = Directory.GetLogicalDrives().Where(d => Directory.Exists(Path.Combine(d, "Dossier1"))).ToArray(); string Résult = string.Join(", ", drives); if (Résult != "") { if (Directory.Exists(Résult + @"Dossier1\")) { if (Directory.Exists(Résult + @"Dossier1\Dossier2")) { if (File.Exists(Résult + @"Dossier1\Dossier2\BDD_SQLite.db3")) { string DBpath = Résult + @"Dossier1\Dossier2\BDD_SQLite.db3"; } } } }
phil.o
В C# нельзя объявить переменную или метод на уровне пространства имен. Все переменные должны содержаться в классе или структуре.