Built in Delegates in .NET Framework


.NET framework provides several different delegates that provides flexible options

  • Action<T> : Accepts single parameter and returns no value
  • Func<T,TResult> : Accepts a single parameter and returns a value of type TResult.


Example Program for Built-in Delegates in .NET

using System;

 

//Example for Builtin delegate in .NET framework

public static class Program

{

 

    static void Main(string[] args)

    {

 

        Action<string> print = (string s) => Console.WriteLine(s);

 

        //Call above print delegate

        print("Sample Text");

        Func<int, int> square = x => x * x;

 

        //Call above square delegate

        int result = square(5);

 

        Console.WriteLine(result);

 

    }

}

 


Zooming in Winforms Webbrowser Control in .NET
Filtering Datatable with Select Conditions and Sorting in C#.NET
Hiding a property from displaying in Datagridview in C#.NET
Logic to detect if Application is started from Citrix/Terminal Server/PC in C#
Winforms Application.DoEvents Method
Modify XML file with tagname in c#.net
Read Machine IP Address in C#
Check if IIS is running using C#
Implementing IEnumerable in C#
Changing Winform webbrowser control IE version in C#.NET
Set the dropdown width of any combobox based on the data
Difference between Const and ReadOnly
Example for Property Change Notification in C#.NET
Example Program using Delegates and Events in C#
AutoComplete in .NET Winforms TextBox
How to read data from XML String and insert in to table in SQL Server
WebBrowser.navigate Data Submission by Get or Post Methods
Datagridview Paging
Copy Datagridview cell value using ContextMenu
Inserting data in Datatable in C#
Cookie in .NET
Using Control's Child Index and Dock property for achieving desired layout in a form.
Accessing section group inside configuration of web.config
Create File in .NET C#
Change button shape in .net
Dispose vs Finalize in .net




Built in Delegates in .NET Framework