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

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube