New in C#4

bearophile bearophileHUGS at lycos.com
Thu Oct 30 08:29:33 PDT 2008


Janderson:
> It would be nice if this worked with structs as parameters as well:
> 
> struct X {
> 	int a;
> 	int b;
> }
> foo(X x) { }
> foo(x.a = 10, x.b = 20);

At the moment you can do:
foo(X(10, 20));

The docs say: "Struct literals are syntactically like function calls."
So if function calls gain the named arguments, then later you can probably write:
foo(X(b: 20, a: 10));

Bye,
bearophile



More information about the Digitalmars-d mailing list