ActionmyAction = x => Console.WriteLine(x); Console.WriteLine(myAction.ToString()); // Output: "System.Action`1[System.Int32]"
Action myAction = () => Console.WriteLine("Hello World!"); Console.WriteLine(myAction.ToString()); // Output: "System.Action"This example creates an Action delegate instance that takes no parameters and writes "Hello World!" to the console, then calls ToString on this delegate to obtain its string representation. The output shows the delegate type name, which indicates a non-generic Action delegate with no parameters. Overall, the System Action ToString method is a helpful tool for developers working with Action delegates who need to obtain string representations of them for debugging or other purposes.