c# - Best practice for nested using statements? -
I have a code block and I'm using 3 nested I found that using you can remove Edit: As John Skeet Said, you should declare using the variable-statement blocks
can finally use the blocks to avoid it, but if the statements are more than two using, then what is the best way is?
Private file stream file stream = null; Private document document = null; Private PDFDriver pdfWriter = Faucet; Using {{FileSize = New Document (PageSize.A4, marginLeft, MarginRight, marginTop, marginBottom) using FileStream = New FileStream ("ABC.pdf", FileMode.Create)) {Using (pdfWriter = PdfWriter.GetInstance (document, fileStream) {document.AddAuthor (metaInformation ["author"]); document.AddCreator (metainformation ["creator"]); document.AddKeywords ("I report report using text"); Document.AddSubject ("Document Subject"); Document.AddTitle ("Document Title"); }}}}
nesting jagging By the way: using the file format (new fileStream ("ABC.pdf", FileMode.Create) (using FILEDocument = new document (PageSize.A4, using
MarginLeft, marginRight, marginTop, marginBottom); (pdfWriter = PdfWriter.GetInstance (document, filestream)) {// code}
Comments
Post a Comment