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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:21:49+00:00 2026-05-31T16:21:49+00:00

I declared a delegate: public delegate void Del(string message); Then i created a function

  • 0

I declared a delegate:

public delegate void Del(string message);

Then i created a function that i want to add to the delegate:

public static void DelegateMethod(string message)
{
    System.Console.WriteLine(message);
}

Now I add the function to the delegate and call it:

Del handler = new Del( DelegateMethod);
handler("Hello World");
Console.Read();

Why when I drop the static from the DelegateMethod do I get an error?

Why does the function I delegate have to be static?

  • 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-31T16:21:51+00:00Added an answer on May 31, 2026 at 4:21 pm

    why when i drop the “static” from the DelegateMethod i get an error?

    Because you are writing this code inside a static method. Given the fact that you are using Console.Read I presume you have put this code inside the static void Main method of your console application. If you wanted to drop the static keyword from the method you will need an instance of the class containing this method. Like this:

    class Program
    {
        public delegate void Del(string message);
    
        public void DelegateMethod(string message)
        {
            System.Console.WriteLine(message);
        }
    
        static void Main()
        {
            Del handler = new Del(new Program().DelegateMethod);
            handler("Hello World");
            Console.Read();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If i declare a delegate public delegate void firstDelegate(string str); firstDelegate handler = Strfunc;
I have declared a generic event handler public delegate void EventHandler(); to which I
When I try to compile the following: public static delegate void MoveDelegate (Actor sender,
Let's say that I have the following delegate: public delegate void Example(); and a
I've got following code in c# public class Shedluer { public delegate void TaskCompletedDelegate(ulong
I'm trying to get the following thing done: public delegate void SomeMethod(params object[] parameters);
I have this delegate declaration: public delegate IEnumerable<T> SearchInputTextStrategy<T, U>(string param); Lets assume I
In my main class 'A' I have declared a function and delegate to call
such as: int i; or public delegate void MyAwesomeDelegate(int i); We have the word
I understand that an action is just a pre-declared delegate that can accept a

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.