Re: Console Application
Chris Anderson <[email protected]> Tue, 11 Dec 2007 19:16:38 -0000
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
> 1. Main is declared as static. As a result, I can't directly call > MyConsoleApp.Initialize() from within Main. I can take the approach of > either creating my methods as static, or writing something like this in > main: ... > Which approach do you take in your console apps, and why? I create an object then use it from main() Why? Fewer "static"s to type, and I can write multithreaded console apps safer. Mainly because I'm lazy though :) > 2. I'd like to use a 'using' instead of a try/finally block, but MyApp > doesn't implement IDisposable, hence the following code won't compile: Why? If you must, you could implement IDisposable, but with empty stubs, etc, but what is it giving you? If you are using "using", you can't add anything to the finally block so it will just call dispose (which is not doing anything), and if you want to catch any exceptions, you're going to have to use "try..catch" anyway! Why not just forget about using either? Chris