|
|
|
|
|
by ygra
4480 days ago
|
|
It gets rid of excessive nesting when you need multiple resources allocated after another (e.g. SqlConnection, SqlCommand, etc.). You can do using (handle a = new handle(0), b = new handle(1), c = handle(3)) {
// use a, b, c
}
instead, too, but that obviously only works with equal types.I'm usually not a friend of too deep nesting (worst thing I've seen in our codebase was 65 spaces deep) and in C# you already have one level for the class, one for the namespace (possibly) and another for the method. No need to add two more if you can help it. |
|