Are C# destructors the same as C++ destructors?
No. They look the same but they are very different. The C# destructor syntax (with the familiar ~ character) is just syntactic sugar for an override of the System.Object Finalize method. This Finalize method is called by the garbage collector when it determines that an object is no longer referenced, before it frees the memory associated with the object. So far this sounds like a C++ destructor. The difference is that the garbage collector makes no guarantees about when this procedure happens. Indeed, the algorithm employed by the CLR garbage collector means that it may be a long time after the application has finished with the object. This lack of certainty is often termed ‘non-deterministic finalization’, and it means that C# destructors are not suitable for releasing scarce resources such as database connections, file handles etc.To achieve deterministic destruction, a class must offer a method to be used for the purpose. The standard approach is for the class to implement the IDisposable interface. The user of the object must call the Dispose() method when it has finished with the object. C# offers the ‘using’ construct to make this easier.
ASP.NET 2.0 Interview Questions
24. While developing ASP.NET 2.0 web application you have a DataSet containing a Customer DataTable and an Order DataTable. You want to easily navigate from an Order DataRow to the Customer who placed the order. What object will allow you to easily navigate from the Order to the Customer? A. The DataColumn object B. The DataTable object C. The DataRow object D. The DataRelation object
25. Which of the following is a requirement when merging modified data into a DataSet? A. A primary key must be defined on the DataTable objects. B. The DataSet schemas must match in order to merge. C. The destination DataSet must be empty prior to merging. D. A DataSet must be merged into the same DataSet that created it.
26. You are working with a DataSet and want to be able to display data, sorted different ways. How do you do so? A. Use the Sort method on the DataTable object. B. Use the DataSet object’s Sort method. C. Use a DataView object for each sort. D. Create a DataTable for each sort, using the DataTable object’s Copy method, and then Sort the result.
27. Which of the following ways can you proactively clean up a database connection’s resources? A. Execute the DbConnection object’s Cleanup method. B. Execute the DbConnection object’s Close method. C. Assign Nothing (C# null) to the variable that references the DbConnection object. D. Create a using block for the DbConnection object.
29. What event can you subscribe to if you want to display information from SQL Print statements? A. InfoMessage B. MessageReceived C. PostedMessage D. NewInfo
30. To perform asynchronous data access, what must be added to the connection string? A. BeginExecute=true B. MultiThreaded=true C. MultipleActiveResultSets=trueD. Asynchronous=true
31. Which class can be used to create an XML document from scratch? A. XmlConvert B. XmlDocument C. XmlNew D. XmlSettings
32. Which class can be used to perform data type conversion between .NET data types and XML types? A. XmlType B. XmlCast C. XmlConvert D. XmlSettings