Theme-Logo
  •   .Net
    •   C Sharp(C#)
    •   Web API
    •   Micro Services
    •   ASP.Net
    • ASP.Net MVC
    • .Net Core
  •   Database
    • SQL Server
    • Oracle
    • PostgreSQL
  •   jQuery
    • jQuery Tutorials
    • jQuery Plugins
    • jQuery UI
    • More on jquery
  •   Tutorials
    • Microservices Tutorials
    • DotNet Core Tutorials
    • PostgreSql Tutorials

Understanding Anonymous method in C#

An anonymous function is an "inline" statement or expression that can be used wherever a delegate type is expected. You can use it to initialize a named delegate or pass it instead of a named delegate type as a method parameter.

You can use a lambda expression or an anonymous method to create an anonymous function. We recommend using lambda expressions as they provide more concise and expressive way to write inline code.

Anonymous methods are the methods without a name, just the body.
                                delegate void CheckNumber(int n);
                                // below is Anonymous body [without name]
                                CheckNumber cn = delegate(int x) {
                                   Console.WriteLine("Anonymous Method: {0}", x);
                                };
                        

The delegate could be called both with anonymous methods as well as named methods in the same way, i.e., by passing the method parameters to the delegate object.

                        cn(10);
                        
Trending Post
What are the effects methods used in jQuery?.
What are the categories in jquery Events?
What is the difference between the ID selector and class selector in jQuery?
What is the difference between onload() and document.ready() methods?
What is the advantage of hosting a jQuery using a CDN?
What is the difference between bind() vs live() vs delegate() methods in jQuery?
Explain the difference between jquery.size() and jquery.length?
Explain the difference between $(this) and this in jQuery?
Interview Questions and Answers
What are JQuery selectors?
What are the different types of Selectors?
What is jQuery.noConflict?
About us

DotNet Palace is a community platform created and maintained by The articles are mainly focused on Microsoft stack technologies like C#, ASP.Net, MVC, .Net Core, SQL Server and Oracle, PostgreSQL, SQLite etc. To improve the site's content you can send your valuable suggestions at info.dotnetpalace@gmail.com

Quick links
  • SOLID Principles
  • Questions
  • OOPS Principles
  • DotNet Palace Tutorials
  • Privacy Policy
  • Terms and Condition