/ Published in: C#

Snippet to show how to create a generic function to have a using/with statement for an object that has already been created.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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"; });
Comments
