4 ms·
That actually looks terrible to me, but I don't program in C#. Mostly it's because there are three blocks, but it only looks like there's one.
by dkuntz2 13y ago
That actually looks terrible to me, but I don't program in C#.
Mostly it's because there are three blocks, but it only looks like there's one.
- ygra 13y agoIt 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.
- dkuntz2 13y agoRight, I understand that it removes excessive nesting, but the first example just looked ... wrong to me. Your example with above looks somewhat better.