OUTPUT 1111 OUTPUT 200 and 3000
This is a C# Program to illustrate actions.
This C# Program Illustrates Actions.
Here action objects return no values.
Here is source code of the C# Program to Illustrate Actions. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Illustrate Actions */ using System; class Program { static void Main() { Action<int> action1 =(int x) => Console.WriteLine("OUTPUT {0}", x); Action<int, int> action2 =(x, y) => Console.WriteLine("OUTPUT {0} and {1}", x, y); action1.Invoke(1111); action2.Invoke(200, 3000); Console.Read(); } }
This C# program is used to illustrate actions. We are creating two objects ‘action1’ and ‘action2’ using Action<int>. The Action<int> is used to encapsulate a method that has a single parameter and does not return a value. Here Action objects return no values. Pass the values of ‘action1’ and ‘action2’ variables as an argument to Invoke().
OUTPUT 1111 OUTPUT 200 and 3000