Is there any difference between these two code samples and if not, why does using exist?
using
StreamWriter writer; try { writer = new StreamWrite
Is there any difference between these two code samples
Yes, using checks for null before calling Dispose (i.e. the actual code it is expanded to introduces a null check).
null
Dispose
why does using exist?
Because the code is more concise. Just a syntactic sugar.