Return to Snippet

Revision: 64694
at September 10, 2013 02:58 by kwhite1975


Initial Code
public static class Utilities
    {
        public static void Use<T>(this T item, Action<T> work)
        {
            work(item);
        }
    }

Object.InnerObject.Use( i => {
     i.Foo = bar;
     i.Text = "Set this here";
});

Initial URL

                                

Initial Description
Snippet to show how to create a generic function to have a using/with statement for an object that has already been created.

Initial Title
Lambda Expression Using Statement with object

Initial Tags

                                

Initial Language
C#