Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 269199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:47:56+00:00 2026-05-11T23:47:56+00:00

I am curious as to how other developers use delegates and/or events other than

  • 0

I am curious as to how other developers use delegates and/or events other than for responding to UI events? I, personally, don’t use them for anything other than responding to UI events but I have a strong feeling that I am missing out on the power of delegates and events. So I pose this question to the SO community so that I may get some ideas on how I could possibly add these tools to my arsenal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T23:47:56+00:00Added an answer on May 11, 2026 at 11:47 pm

    Events are pretty mundane. Most often you’ll be using them in response to UI or when developing components that have to inform users about state changes. Yawn.

    Delegates, however, are full of awesome and win. Probably the most common use is in Linq. Linq uses lambdas all over the place, which are shorthand delegates.

    var numbers = new int[]{1,2,3,4,5};
    var evenStevens = numbers.Where(x => x % 2 == 0);
    

    Another common use is in multithreading:

    ThreadPool.QueueUserWorkItem(o => DoWork(o));
    

    Where I’ve used them that I like the most is in HtmlHelper extension methods that mix rendering html with codebehind:

        /// <summary>
        /// Helps render a simple list of items with alternating row styles
        /// </summary>
        /// <typeparam name="T">The type of each data item</typeparam>
        /// <param name="html">The HtmlHelper.</param>
        /// <param name="rows">The list of items</param>
        /// <param name="rowTemplate">The row template.</param>
        /// <param name="evenCssClass">The even row CSS class.</param>
        /// <param name="oddCssClass">The odd row CSS class.</param>
        public static void SimpleList<T>(
            this HtmlHelper html,
            IEnumerable<T> rows,
            Action<T, string> rowTemplate,
            string evenCssClass,
            string oddCssClass)
        {
            var even = false;
            foreach (var row in rows)
            {
                rowTemplate(row, even ? evenCssClass : oddCssClass);
                even = !even;
            }
        }
    

    an example of its use in an aspx file:

    <div id="nodes" class="scrollingBlock">>
        <%  Html.SimpleList(
              Model.Nodes,
              (d, css) =>
              {%>
          <div class='<%=css%>'><%=d.Name %></div>
              <%}, "evenRow", "oddRow");%>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is no rhyme or reason for this question other than I was curious
I have a couple special use cases for Django admin, and I'm curious about
I'm curious to see how other developers go about testing their web sites. PHP
I am curious as to what, if any, security concerns other develpers have in
I am curious how other Resharper users deal wih R#'s complaint about virtual methods
I am curious as to how other development teams spec out new features. The
I'm curious as to what sort of standards other teams make sure is in
I'm curious how others have solved this problem, and what problems might lurk behind
I am curious how others would handle this situation. I have a domain layer
Curious whether folks have setup 2 way transactional replication on the tables ASP.NET uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.