Wednesday, March 26, 2008

Mathematical function in VS 2008

In Visual Studio 2008, we can make a function like mathematics.

For example, I have a function like :

f(x) = x +1, x is element of integer,

You can make in the VS 2008 like :

Func<int,int> f = (x) => x + 1;

I think it is a nice feature, since we can make many mathematics function in the short statement. The declaration above using new feature of Lambda Expression that is available in the Visual Studio 2008. You can just use the function above like:

int result = f(3);

0 comments: