Letters from Readers

Letters: Looking into Lambdas

C# Corner columnist Patrick Steele recently explored the idea of using lambda methods as a way to plug in specific functionality with more control than subclassing ("Lambda Properties: An Alternative to Subclassing?" June 2011). Readers respond:

I think this is a great idea for those edge instances where you need a slight variation for one or two places in the code and creating an entire subclass is more work than it's worth.

Sean Cooper
Chicago, Ill.

I agree with Sean. While you wouldn't want to replace inheritance with this approach, I can see the power of it. It's certainly something that I'll keep in mind as I develop -- especially when writing unit tests. Thanks!

Reese
Spokane, Wash.

I would opt for creating methods that take a Func as a parameter. This is an example of the Strategy pattern.

Robert Zurer
New York, NY

Missing Tools
What about NuGet? And ReSharper [missing from the June 2011 "Visual Studio Toolapalooza"]?

Bill Mild

Peter Vogel responds: I'm a big fan of ReSharper, but it doesn't have a free version (at least, not one I could find). And I was going to include NuGet, but Ian Davis beat me to it in his recent Open Source .NET column online. So I was out of luck. They're still great tools, though.

If you just want to dump the e-mail to a folder, you don't need a program to do that. Just set the SmtpClient's DeliveryMethod property to SpecifiedPickupDirectory, and set the PickupDirectoryLocation property to the path where you want the files to be generated. (You can even do this in the config file for a no-code change.) The generated files will be standard EML files, which you can open with Outlook Express or Windows Live Mail.

Richards

Peter Vogel responds: There's nothing wrong with setting the DeliveryMethod property -- provided, of course, you remember to change the setting before releasing to production (let's not ask why I know this). But I still need to either use some client to view the mail or find my way to the folder to check my results. The nice thing about tools like papercut and smtp4dev is that they come with a client and the client sits right in the tray, making it easy to see my results.

About the Author

This story was written or compiled based on feedback from the readers of Visual Studio Magazine.

comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube