Action<T>

Overview

The Blocks that has a single parameter and does not return a value. This block is used to perform an action on an object with specific type.

Use case

You can use this block to represent a method that will perform some action on the object.

For example if you need to iterate each item in the list you can use List<T> method that takes an Action block:

var Items := new List<String>(["One", "Two", "Three"]);
Items.ForEach(method (item: String) begin
                DoSomething(item);
              end);

In this example we've used an anonymous method, but it can be used with a static method or lambda expression:

Items.ForEach(item -> DoSomething(item));

Location

  • Reference: Sugar
  • Namespace: Sugar.Collections
  • Ancestry: MulticastDelegate | Action<T>

See Also

  • Blocks
  • Anonymous Methods
  • Anonymous Methods