A very simple example would be as follows :
[TestMethod] public void ExecuteFunctionalTechnique() { TryCatchTemplate(() => { new Babolat().StringRacquet(); }); } private void TryCatchTemplate(Action body){ try { body(); } catch (Exception) { throw; } }
It gets more fun when you have to return a value from the anonymous delegate and you don't want to commit to a type (yay, generics). A simple example is as follows:
BindSelect<IList<Role>>( selRoles, "ID", "Name", Role.GetAllRoles );
private void BindSelect<T>(HtmlSelect securityDropDown, string dataMemberName, string dataText, Func<T> collectionToBind) { securityDropDown.DataSource = collectionToBind(); securityDropDown.DataValueField = dataMemberName; securityDropDown.DataTextField = dataText; securityDropDown.DataBind(); }
Have fun!