static bool init_access(string file_path) { string[] fileLines; /*Try catch for file not being present*/ try { fileLines = System.IO.File.ReadAllLines(@file_path); } catch { Console.WriteLine("File not Found"); return(false); } foreach (string line in fileLines) { string[] words = line.Split(' '); if (words[0].Length > 5 || words[0].Any(char.IsDigit)) { return(false); } /*If the Admin user wishes to comment out a entry, a '/' can be put in front of the name*/ if (words[0][0] != '/') { ConsoleApplication1.User u = new ConsoleApplication1.User(words[0]); foreach (string word in words.Skip(1)) { /*Try catch for if one of the access screens is not an int*/ try { /*Checks the access number is between 0 and 9*/ if (Int32.Parse(word) > 9 || Int32.Parse(word) < 1) { return(false); } u.addAccess(Int32.Parse(word)); } catch { return(false); } } users.Add(u); } } return(true); }
static void Main(string[] args) { User u = new ConsoleApplication1.User("raju", "Uttarkhand", 32); Console.WriteLine("Name:{0}, Location:{1}, Age:{2}", u.name, u.location, u.age); }