Archive

Posts Tagged ‘Anonymous’

The Introduce ForEach Action refactoring

August 28th, 2012 1 comment

It is a rather trivial task to iterate over each item of the generic List using a foreach-loop as follows:

ForEach-loop iteration

Read more…

Code Issues for anonymous methods and lambda expressions

October 31st, 2011 Comments off

We already reviewed the refactorings for anonymous methods and lambda expressions and know how to deal with these language structures. Now its time to review what Code Issues for anonymous methods and lambda expressions CodeRush Pro provides.

Read more…

Refactorings for anonymous methods and lambda expressions

September 27th, 2011 Comments off

An anonymous method is a method without a name – which is why it is called anonymous. You don’t declare anonymous methods like regular methods. Instead, they get declared right inside a member as an inline code block. This is one of the greatest benefits of an anonymous method – it removes the requirement to create a named method elsewhere in the code, especially for simple operations. For example, you are able to pass an inline anonymous method as a delegate parameter, which means that you can use anonymous methods anywhere a delegate type is expected:

Refactor! Anonymous method sample code

Read more…

Refactorings for anonymous types

September 27th, 2011 Comments off

Anonymous types are type declarations that are generated automatically by the compiler without having to explicitly declare it. They provide a convenient way to encapsulate several read-only properties into a single object that is not declared in the code. Anonymous types are supported by C# and Visual Basic programming languages starting from Visual Studio 2008.

Read more…