Hi, Hugo.
>>Instead, C# has powerful and meaningful constructions like "using", which provides an execution context for a disposable resource, simplifying the error handling code VERY much.
>
>You lost me. Evidently as it can be read in my previous message to Claudio, I am not sure if I agree; of course it is for my limited knowledge, and I am not even sure I understand what you are saying and how you simplify error handling with the using directive. If it is not too much trouble can you give an example to the simple folks?
Sure. Here's one simple example (not checked, so some syntax error could have slipped in):
public void ExecuteCommand( string connectionString, string commandString ) {
using ( SqlConnection aConnection = new SqlConnection(connectionString) ) {
using ( SqlCommand aCommand = new SqlCommand( aCommand, aConnection )){
aConnection.Open();
aCommand.ExecuteNonQuery();
}
}
}
There you have two nested using taking care of two different disposable resources and you don't have to use try/catches to manage potential exceptions in the middle, because they'll be disposed in any case. You can write the same with try/catches, but it will get quite messy.
Hope this clears my point.
Regards,