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 7730473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:13:58+00:00 2026-06-01T06:13:58+00:00

With the [attribute] notation I can attach custom attributes to class instance methods. But

  • 0

With the [attribute] notation I can attach custom attributes to class instance methods. But if I write code like

menu.handlers[MOUSECLICK] += (clickEvent)delegate(event e) { ... };

the [attribute] notation seems not to be available. Am I limited to attributes for methods declared out of line, or is there a way to somehow do them for in-line anonymous methods declared using delegate() { … }?

(I happen to like the inline style: you have easy access to in-scope variables and I think it makes for a nicer and more compact kind of code where you can see what the event handler will do at the same place where you register it…)

  • 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-06-01T06:14:00+00:00Added an answer on June 1, 2026 at 6:14 am

    The anonymous method is defined in-line and not as a member method of
    any class. Additionally, there is no way to apply custom attributes to
    an anonymous method, nor can the anonymous method define generic types
    or add generic constraints.

    Quoting from the MSDN Article – Create Elegant Code With Anonymous Methods, Iterators, And Partial Classes

    In Short NO!, You cannot add custom attributes for Anonymous methods

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With bracket notation I can access a direct child node by name or attribute
I created an inherited attribute like this in ASP.NET MVC3: public sealed class RequiredFromResourceAttribute
I have a custom attribute: public class MenuItemAttribute : Attribute { } and a
[Authorize] attribute is nice and handy MS invention, and I hope it can solve
session.createQuery(Select attribute from GoodsSection tgs + join gs.ascendants ags join ags.attributes attribute + where
The xmlns attribute in the following code stops me getting the value I need.
Which column from the attribute can I use as a key when I create
I have an attribute in my model which contains html string like below: <p>Solution
I have the following code in an Active Record file. class Profile < ActiveRecord::Base
I have seen the following code in a website... what does this mean?.Can i

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.