Site: http://www.rationalexpression.org/ Link: http://www.rationalexpression.org/syndication.axd
by gavin via elephantsintheroom.org on 1/19/2008 1:40:03 AM
The Evil method (+ 1 overload and a MemberInfo extension), below, allows traversal of an object graph by string. It works on properties, fields and methods that take no parameters or indexers. usage: string s = person.Evil("Home.Postcode.ToString"); static class ObjectExtension { public static object Evil(this object target , string s) { return target.Evil(s, '.', '\\', '/', ','); } public static object Evil(this object target ...
[ read more ]
by gavin via elephantsintheroom.org on 12/22/2007 4:36:00 PM
The following code gives examples of subscribing to an instance of a void, parameterless delegate using a 'named' method (C# 1.0 and above) an anonymous method (C# 2.0 and above) a lambda expression (C# 3.0) using System; namespace RationalExpression { class Program { //declare the delegate delegate void MinimalDelegate(); static void Main(string[] args) { //create instance of the delegate MinimalDelegate instanceOfMinimalDel ...
by gavin via elephantsintheroom.org on 12/19/2007 1:15:00 AM
Extension methods allow you to create new public methods for a type without having to edit the type's code. They have been used by Microsoft in the implementation of Linq. The following example shows how int[] has been extended with a Min() method. using System.Linq;//without this, the int.Min extension will not be available namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int[] intArray = { 12, 24, 45 }; ...
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.