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

  • Creating Business Applications Using Blazor

    Expert Blazor programmer Michael Washington' will present an upcoming developer education session on building high-performance business applications using Blazor, focusing on core concepts, integration with .NET, and best practices for development.

  • GitHub Celebrates Microsoft's 50th by 'Vibe Coding with Copilot'

    GitHub chose Microsoft's 50th anniversary to highlight a bevy of Copilot enhancements that further the practice of "vibe coding," where AI does all the drudgery according to human supervision.

  • AI Coding Assistants Encroach on Copilot's Special GitHub Relationship

    Microsoft had a great thing going when it had GitHub Copilot all to itself in Visual Studio and Visual Studio Code thanks to its ownership of GitHub, but that's eroding.

  • VS Code v1.99 Is All About Copilot Chat AI, Including Agent Mode

    Agent Mode provides an autonomous editing experience where Copilot plans and executes tasks to fulfill requests. It determines relevant files, applies code changes, suggests terminal commands, and iterates to resolve issues, all while keeping users in control to review and confirm actions.

  • Windows Community Toolkit v8.2 Adds Native AOT Support

    Microsoft shipped Windows Community Toolkit v8.2, an incremental update to the open-source collection of helper functions and other resources designed to simplify the development of Windows applications. The main new feature is support for native ahead-of-time (AOT) compilation.

Subscribe on YouTube