[Israel.pm] C#3 bits

Shmuel Fomberg semuelf at 012.net.il
Wed Nov 12 14:17:18 PST 2008

Hi All.

I've been looking on C#3, and they have lambda expressions now! meaning, 
when you write:
c => c + 1
you actually define an anonymous function that takes one parameter (c) 
and return c+1. The type of "c" is decided by the context of the lambda 
expression definition.
The aren't closures. Man, Perl made me greedy... :-)

They also have anonymous classes. writing:
var p1 = new { Name = "Shovel", Price = 495.0 };
Will create an anonymous class. I still don't know what it's good for, 
because as much as I seen, the fields of this class can not be accessed 
without reflection.

It is possible to declare a variable as "var", like this:
var x = new Customer();
And x will automatically be of type Customer. cute.

And one last, there are Extension functions. if declared:
public static class E
    public static void F(this object obj, int i) { }
    public static void F(this object obj, string s) { }
then every instance of any type, it is possible to class:
and "a" will attached to "obj", i=5.
Here again, I don't know what it's good for. one day.


More information about the Perl mailing list