using InterviewTest; using System.Collections.Generic; using System.Data; //-------------------------------------------------- //Question #1 //-------------------------------------------------- //Here we have a custom Data class that takes 2 parameters. We instantiate an object //and then pass in a SQL command to retrieve all employees from our table. Data myData = new Data(); DataSet ds = myData.GetDataset("SELECT * FROM tblEmployee", false); //Besides the following code, what is another way that you can determine if the //resulting dataset contains any rows if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { Console.WriteLine("We have data!!"); } else { Console.WriteLine("No data returned"); } } } Console.ReadLine(); //Answer to question #1 //One solution would be to write an extension method to extend the funtionality of the DataSet object (see the extension method in the Data class) //-------------------------------------------------- //Question #2 //-------------------------------------------------- //What will be written out to the console? string Value = "Microsoft"; var result = Value.Any(x => char.IsUpper(x)); Console.WriteLine(result); Console.ReadLine(); //Answer to question #2 //The output would be TRUE since the .Any() method returns a boolean value //-------------------------------------------------- //Question #3 //-------------------------------------------------- //We attempt to connect to a SQL server instance that is on our local network, however the following error messsage is returned // // "The certificate chain was issued by an authority that is not trusted" // //What can we add to the connection string that will allow us to successfully connect to the server? string connString = "Server=192.168.1.100;Database=PROMS;User Id=PromsUser;Password=S3cur3P@ssw0rd;"; //Answer to question #3 //You would add "TrustServerCertificate=true" to the end of the connection string //-------------------------------------------------- //Question #4 //-------------------------------------------------- //What will be the output that is written to the console? static void Main(string[] args) { int num = 2; myFunc(ref num); Console.WriteLine(num); Console.ReadLine(); } static void myFunc(ref int num) { num = num * num * num; } //Answer to question #4 //The output would be 8 //-------------------------------------------------- //Question #5 //-------------------------------------------------- //What will be the output that is written to the console? public class emp { public string name; public string address; public void display() { Console.WriteLine("{0} is in city {1}", name, address); } } public class MyProgram { public static void GetName() { emp obj = new emp(); obj.name = "Sam"; obj.address = "Pittsburgh"; Console.ReadLine(); } } //Answer to question #5 //Nothing would be written to the console since the Display() method is never called ////-------------------------------------------------- ////Question #6 ////-------------------------------------------------- //What would the output be of the following code block? Test obj = new(); Test.first(); obj.second(10); Console.ReadLine(); public class Test { public static void first() { Console.WriteLine("first method"); } public void second() { first(); Console.WriteLine("second method"); } public void second(int i) { Console.WriteLine(i); second(); } } //Answer to question #6 // first method // 10 // first method // second method