Last time I wrote about comparing XML strings in .NET, and continuing that theme I’d like to discuss another handy XML trick. As the last article pointed out, not all XML strings are created equal. In fact, sometimes they are missing the necessary XML version and encoding information, like in the following sample XML:
Sometimes an exception isn’t just an exception. For example, SQL can have connection or timeout issues and file IO can have problems competing for file access. In these situations, sometimes it makes sense to try executing the code again rather than letting it completely error out. Below is some C# sample code for executing some simple retry logic.
The C# HashSet<T> data structure was introduced in the .NET Framework 3.5. It is a very powerful data structure with no duplicate values. It comes with a bunch of built-in set functions. It inherits the ICollection interface, so the elements inside a HashSet can only be accessed through an enumerator.
In the System.Data.SqlClient namespace, SqlConnection and SqlCommand are two examples of managed types that use unmanaged resources down in the COM layer of the run-time. Microsoft says that all of these types must implement the IDisposable interface.
Recently, I needed to transmute a Web form into Windows form for a client. There was a subtle issue involving parameters to a SQL stored proc; the stored proc returned matches and near matches to the input values. The return values were missing special characters like ampersand (&).
The solution was to import the Microsoft.JScript assembly and call the Microsoft.JScript.GlobalObject.escape() method.