Anonymous functions, in a simple way, are functions that can be activated directly without declaring his name, as his own name says "anonymous".
This technic works in C# projects, .NET Framework, .NET Core or WPF and can be used to reduce code, on this POST I attached a sample of using anonymous X common (regular) way.
The final result is a reduced code and fast startup.
The common way
Below is a regular code for fired Click events. To run this Form there is extra code in FormCommon.Designer.cs.
FrmCommon.cs
- using System;
- using System.Windows.Forms;
- namespace AnonymousEventsForClick
- {
- public partial class FrmCommon : Form
- {
- public FrmCommon()
- {
- InitializeComponent();
- }
- private void menu1ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- // Your code
- // CODE xyz
- var n = 0;
- APIProject.Print(++n);
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- APIProject.CheckStatus();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- // Sample to access the object
- if (!(sender is Button)) return;
- APIProject.OpenDocument();
- }
- }
- }

Sourav Kumar DasPosted Oct 22, 2019, 2:23 AM
Superb Article Sir.
Praneet RanePosted Oct 21, 2019, 2:54 AM
Nice information!
Hari MurugesanPosted Oct 21, 2019, 2:21 AM
Nice Article